Reputation: 833
Do I understand correctly that you cannot create a new Cloud Run service revision via the API ?
Looking under Revisions : https://cloud.google.com/run/docs/reference/rest/v1/namespaces.revisions : "Revisions are created by updates to a Configuration."
If we then check "Configurations" : https://cloud.google.com/run/docs/reference/rest/v1/namespaces.configurations : we only have a GET and a LIST method.
Upvotes: 0
Views: 747
Reputation: 75755
It's not so hard, but you need to know well the Cloud Run service first. Cloud Run implement the Knative API and one of the strength of Cloud Run is to guaranteed the portability on Cloud Run and on any K8S cluster that use Knative on top of it.
Thus,
namespace_id
on Cloud Run managed is your Project_ID
.curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-type: application/json" \
-X POST -d @knative.json \
https://us-central1-run.googleapis.com/apis/serving.knative.dev/v1/namespaces/<Project_ID>/services
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-type: application/json" \
-X PUT -d @knative.json \
https://us-central1-run.googleapis.com/apis/serving.knative.dev/v1/namespaces/<Project_ID>/services/<ServiceName>
Because Cloud Run is compliant with Knative, the content of the file knative.json
is a Knative document (in JSON in my example)
{
"apiVersion": "serving.knative.dev/v1",
"kind": "Service",
"metadata": {
"name": "<ServiceName>",
"namespace": "<Project_ID>"
},
"spec": {
"template": {
"spec": {
"containers": [
{
"image": "gcr.io/knative-samples/helloworld-go",
"env": [
{
"name": "TARGET",
"value": "Go Sample v2"
}
]
}
]
}
}
}
}
Note in this document the service Name and the Namespace (projectID) that you need to change.
Upvotes: 2