dinigo
dinigo

Reputation: 7438

Google Deployment Manager Cloud Scheduler type

I see there's no schedule type provided by GCP. I'd like to know the steps to create a template, a composite-type or similar, to provide Cloud Scheduler type. I know Google already provides an example about it.

If it's posible to do so by code It could make use of the python client library though it says in the documentation this library is not available, I could inline it in the code.

I cannot think of a way to authenticate against the google API to do such requests.

In short, my question is how can make Deployment Manager type for Cloud? I know it is sort of vague. Just want to know if it would be doable.

On the other hand, where can I find the official development for this GCP service?

For completenesss here's the related Github issue too

Upvotes: 2

Views: 1155

Answers (3)

Kamko
Kamko

Reputation: 69

You can use general YAML file with deployment-manager:

config.yaml:

resources:
  - name: <<YOUR_JOB_NAME>>
    type: gcp-types/cloudscheduler-v1:projects.locations.jobs # Cloud scheduler
    properties:
      parent: "projects/<<YOUR_PROJECT_NAME>>/locations/<<YOUR_LOCATION_ID>>"
      description: "<<JOB_DESCRIPTION_OPTIONAL>>"
      schedule: "* */2 * * *" # accepts 'cron' format
      http_target:
        http_method: "GET"
        uri: "<<URI_TO_YOUR_FUNCTION>>" # trigger link in cloud functions

You even can add to create a Pub/Sub job and other with deployment-manager just add :

  - name: <<TOPIC_NAME>>
    type: pubsub.v1.topic
    properties:
      topic: <<TOPIC_NAME>>
  - name: <<NAME>>
    type: pubsub.v1.subscription
    properties:
      subscription: <<SUBSCRIPTION_NAME>>
      topic: $(ref.<<TOPIC_NAME>>.name)
      ackDeadlineSeconds: 600

NOTE: to get <<YOUR_LOCATION_ID>> use gcloud app describe.

To deploy use: gcloud deployment-manager deployments create <<DEPLOYMENT_NAME>> --config=<<PATH_TO_YOUR_YAML_FILE>>

To delete use: gcloud deployment-manager deployments delete <<DEPLOYMENT_NAME>> -q

For more properties on Cloud Scheduler read the documentation: https://cloud.google.com/scheduler/docs/reference/rpc/google.cloud.scheduler.v1#google.cloud.scheduler.v1.HttpTarget

Upvotes: 2

Joel Biffin
Joel Biffin

Reputation: 378

I was looking for this functionality and thought I should give an up to date answer on the topic.

Thanks to https://stackoverflow.com/users/9253778/dany-l for the feature request which led me to this answer.

It looks like this functionality is indeed provided, just that the documentation has yet to be updated to reflect it.

Here's the snippet from https://issuetracker.google.com/issues/123013878:

  - type: gcp-types/cloudscheduler-v1:projects.locations.jobs
    name: <YOUR_JOB_NAME_HERE>
    properties:
      parent: projects/<YOUR_PROJECT_ID_HERE>/locations/<YOUR_REGION_HERE>
      name: <YOUR_JOB_NAME_HERE>
      description: <YOUR_JOB_DESCRIPTION_HERE>
      schedule: "0 2 * * *" # daily at 2 am
      timeZone: "Europe/Amsterdam"
      pubsubTarget:
        topicName: projects/<YOUR_PROJECT_ID_HERE>/topics/<YOUR_EXPECTED_TOPIC_HERE>
        data: aGVsbG8hCg== # base64 encoded "hello!"

Upvotes: 4

dany L
dany L

Reputation: 2654

Cloud Scheduler type is not supported yet according to GCP's documentation.

I am not aware of any official development for this GCP service other than the one I linked above. That being said, I will create a feature request for your use case. Please add any additional that I have missed and you may use the same thread to communicate with the deployment manager team.

Upvotes: 4

Related Questions