Pindar / gcloud-k8s-express-app

Idea to Production, Use Gitlab and Kubernetes for continuous deployments
8 stars 3 forks source link

Migrating setup/teardown-scripts to deployment manager #2

Open Pindar opened 7 years ago

Pindar commented 7 years ago

I was thinking about alternatives to my setup/teardown scripts. One was to use terraform #1 . The other solution might be to use deployment-manager. I was lucky enough to get the cluster created with this example but I haven't seen any possibility in their documentation to create either a new project or to create service accounts.

If anyone knows how to deal with it please let me know. Otherwise I don't see the point to change the cluster deployment from a one-liner to a multi-file setup.

Pindar commented 7 years ago

from the output of gcloud deployment-manager types list it seems that iam.v1.serviceAccount is supported.

resources:
- name: test-gitlabci-k8s-1
  type: iam.v1.serviceAccount
  properties:
    accountId: "gitlab-ci-token-1"
    displayName: "Account is used to deploy to Kubernetes from Gitlab CI"

works to create the service account but not to set Iam Policy. Has someone an example for me?

Pindar commented 7 years ago

There is a new blog post about it https://cloudplatform.googleblog.com/2017/04/automating-project-creation-with-Google-Cloud-Deployment-Manager.html?m=1

Pindar commented 7 years ago

Didn't get the Deployment Manager working with the blog instruction. If anyone knows more let me know.

gcloud deployment-manager deployments create pj-sd-gitlabci-k8s-2017-04-24-10-28 --config config.yaml --project $MY_CREATION_PROJECT
The fingerprint of the deployment is ABCDEFG==
Waiting for create [operation-1493024498717-54de5dae31149-∞-…]...failed.
ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1493024498717-54de5dae31149-∞-…]: errors:
- code: RESOURCE_ERROR
  location: /deployments/pj-sd-gitlabci-k8s-2017-04-24-10-28/resources/sd-gitlabci-k8s
  message: '{"ResourceType":"cloudresourcemanager.v1.project","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"Request
    contains an invalid argument.","status":"INVALID_ARGUMENT","statusMessage":"Bad
    Request","requestPath":"https://cloudresourcemanager.googleapis.com/v1/projects"}}'

As reference my question in Slack https://googlecloud-community.slack.com/archives/C48GEKY9Z/p1493025347225247

Pindar commented 7 years ago

My gcloud Version:

gcloud --version Google Cloud SDK 152.0.0 alpha 2017.03.24 beta 2017.03.24 bq 2.0.24 bq-nix 2.0.24 core 2017.04.14 core-nix 2017.03.24 gcloud gcloud-deps 2017.04.07 gcloud-deps-darwin-x86_64 2017.03.31 gsutil 4.25 gsutil-nix 4.23

Pindar commented 7 years ago

solution:

It seems your "name" in your config.yaml is too long, project names should only be around 4 to 30 characters, "sd-gitlabci-k8s-2017-04-24-10-28" seems to be 32 characters which is more than the allowed project name length.

Happy to get it working.