Giter Club home page Giter Club logo

gcp-gke-orb's Introduction

GCP: GKE Orb CircleCI Build Status CircleCI Orb Version GitHub License CircleCI Community

A GKE Orb for CircleCI. It allows you to interact with Google Cloud Platform's (GCP) Google Kubernetes Engine (GKE) from within a CircleCI build job.

Prerequisites

The following environment variables need to be set in CircleCI either directly or via a context:

  • GCLOUD_SERVICE_KEY (required)
  • GOOGLE_PROJECT_ID
  • GOOGLE_COMPUTE_ZONE
  • GOOGLE_COMPUTE_REGION

See CircleCI Documentation for instructions on how you would set this up.

Usage

Example use as well as a list of available executors, commands, and jobs are available on this orb's registry page.

Resources

CircleCI Orb Registry Page - The official registry page for this orb will all versions, executors, commands, and jobs described. CircleCI Orb Docs - Docs for using and creating CircleCI Orbs. Google Cloud Platform (GCP) Docs - General docs for GCP. GCP: Google Kubernetes Engine (GKE) Docs - GCP Docs specifically on GKE.

Contributing

We welcome issues to and pull requests against this repository! For further questions/comments about this or other orbs, visit the Orb Category of CircleCI Discuss.

gcp-gke-orb's People

Contributors

anoriqq avatar cpe-bot avatar dsayling avatar eddiewebb avatar ericribeiro avatar felicianotech avatar iynere avatar jaryt avatar joaomlopes avatar kyletryon avatar lokst avatar mkart14 avatar novedevo avatar zackijack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gcp-gke-orb's Issues

Cannot run update-kubeconfig-with-credentials job

Orb version

1.0.4

What happened

When trying to run the update-kubeconfig-with-credentials job, Circleci build fails with Cannot find a definition for job named gcp-gke/update-kubeconfig-with-credentials.

Expected behavior

The update-kubeconfig-with-credentials is a documented job and its definition should be found by circleci.

Could gcp-gke/create-cluster be idempotent?

Orb version

1.0.4

What happened

First time the pipeline runs the cluster is created.

Subsequently it errors because the cluster already exists...

ERROR: (gcloud.container.clusters.create) ResponseError: code=409, message=Already exists: projects/*********************/zones/**************/clusters/*********************-cluster.

Expected behaviour

Ideally, the command would be idempotent and just apply any changes if the cluster already exists.

Namespace support for updating deployments

Orb version

0.2.0

What happened

(actual container, deployment, etc., names replaced)

$ #!/bin/bash -eo pipefail
gcloud container clusters get-credentials $GOOGLE_CLUSTER_NAME
kubectl set image deployment deployment-foo container-foo=gcr.io/project-foo/container-foo:$CIRCLE_SHA1

Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-foo.
Error from server (NotFound): deployments.extensions "deployment-foo" not found
Exited with code 1

Expected behavior

deployment-foo is in namespace-foo, so kubectl set image deployment uses default namesapce.

I would expect to be able to set the namespace as a parameter for both jobs publish-and-rollout-image and rollout-image

upgrade whatsapp

Describe Request:

   +whatsapp bedge

Examples:

    +name: GitHub Actions Demo

run-name: ${{ github.actor }} is testing out GitHub Actions ๐Ÿš€
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "๐ŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "๐Ÿง This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "๐Ÿ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "๐Ÿ’ก The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "๐Ÿ–ฅ๏ธ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "๐Ÿ This job's status is ${{ job.status }}."

Supporting Documentation Links:

    https://wa.me/6282132702331

doesn't seem to work on k8s

Orb version:

latest one?

What happened:

i've got a report from a customer who says an orb is not working on their container runner within their k8s cluster. we think it's because of this specific part of the orb's logic:

if grep 'docker\|lxc' /proc/1/cgroup > /dev/null 2>&1; then
  if [[ $(command -v gcloud) == "" ]]; then
    install
  else
    echo "gcloud CLI is already installed."
  fi

if the grep string was updated to grep 'docker\|lxc\|kube' /proc/1/cgroup we think this will work on k8s (it seems to work on our test cluster).

Expected behavior:

the orb works on self-hosted runner in k8s just like it works on Cloud.

Additional Information:

i dont trust myself submitting a PR, but it is this line: https://github.com/CircleCI-Public/gcp-cli-orb/blob/master/src/commands/install.yml#L25

Api

Describe Request:

Examples:

Supporting Documentation Links:

Allow to pass gcloud version as a parameter

Describe Request:

A parameter should be added to the orb jobs so that the gcp-cli/setup command won't install the latest version regardless the user intention.
As all jobs in this orb rely on this command, having a breaking change version that can't be controlled by the user will break the pipeline flow and prevent the user from deploying their services.

Examples:

There's an issue with the newest version of gcloud (429.0.0) that will fail on the gcp-cli/setup command.

Supporting Documentation Links:

An issue was created on the gcp-cli orb that can be tracked here
A PR was created to support this change

Docs: Define more explicit use-case example

Describe Request:

Documentation on gcp-gke orb usage is not explicit. As presented in #25, users might expect to be able to have clusters persist between pipeline runs. This is to prevent infrastructure as code managed by CI config. We want to enforce that all infrastructure created in pipeline is ephemeral and MUST be removed by the end of the same pipeline.

Examples:

orbs:
  gke: circleci/[email protected]
version: 2.1
workflows:
  main:
    jobs:
      - gke/create-cluster:
          cluster: gcp-testing
      - run-cluster-command
      - gke/delete-cluster:
          cluster: gcp-testing

Supporting Documentation Links:

https://cloud.google.com/sdk/gcloud/reference/container/clusters/create

Unable to reference publish-and-rollout-image from custom job

This config gives me this error: Cannot find a definition for command named gke/publish-and-rollout-image

version: 2.1
orbs:
  gke: circleci/[email protected]
jobs:
  publish:
    executor: gke/default
    steps:
      - gke/publish-and-rollout-image

workflows:
  main:
    jobs:
      - publish

But if I change the step to one of the other jobs, like create-cluster, it seems to find the job definition. Is this a bug or am I missing something?

docker build fails during job publish-and-rollout-image: dockerfile-dir ignored

Orb version

1.0.4

What happened

docker build fails during job: publish-and-rollout-image. I use dockerfile-die param to specify the location of the dockerfile. The job run can be viewed at: https://app.circleci.com/pipelines/github/christianskovholm/portfolioapp/176/workflows/d9772f1e-ed40-42c7-a5b9-0ae81efbcabb/jobs/232

Expected behavior

docker build should succeed. dockerfile-dir param should set the path/context of the docker build command, however, it seems to be ignored and instead defaults to ${HOME}/project.

[FEATURE] Support tag in deployment

in the rollout_image command, there is no option to add an image tag here

    steps:
      - run: |
          gcloud container clusters get-credentials <<parameters.cluster>>
          kubectl set image deployment <<parameters.deployment>> <<parameters.container>>=<<parameters.image>>

I've patched my local command to add the parameter:

      image_tag:
        description: The images tag version
        type: string
        default: $CIRCLE_SHA1
    steps:
      - run: |
          gcloud container clusters get-credentials <<parameters.cluster>>
          kubectl set image deployment <<parameters.deployment>> <<parameters.container>>=<<parameters.image>>:<<parameters.image_tag>> --record

I think this needs added as I hit an error when there was not tag specified.
I think it will also keep consistency withe the gcp-gcr orb where tag is a parameter

SUPPORT FOR ENV VAR GOOGLE_COMPUTE_REGION

Orb version

0.2.0

What happened

I'm using a GKE cluster in a region which has three nodes. I can't publish with rollout-image since there is only a GOOGLE_COMPUTE_ZONE env var. If I try to put a region into GOOGLE_COMPUTE_ZONE env var Google Cloud throws an error:

ResponseError: code=400, message='zone' field cannot be used to access GKE regional clusters. Use 'name' or 'parent' fields instead.

Expected behavior

Should either work with GOOGLE_COMPUTE_ZONE or add a new GOOGLE_COMPUTE_REGION.

Docker builds for node 14.9 or higher failing: need to be able to set a remote docker version

Orb version:

1.3.0

What happened:

Docker builds for node with base images of node version 14.9.0 or higher are failing with the error

EPERM: operation not permitted, copyfile

This issue is caused by old docker versions. In order to fix it, we need to be able to set the docker version of the remote docker instance.
In Circle CI this is possible by setting

- setup_remote_docker:
    version: 19.03.13

Unfortunately in the orb we cannot provide a version to use with the remote docker instance. There is only a boolean flag.

use-remote-docker: Setup a remote Docker engine for Docker commands? Only required if using a Docker-based executor
type: boolean
default: true 

Expected behavior:

Builds for nodejs 14.9 or higher should work. Either by allowing to set the version of the remote docker instance, or by setting a higher default version when using the use-remote-docker.

Additional Information:

Related Circle CI help article: https://support.circleci.com/hc/en-us/articles/360050934711-Docker-build-fails-with-EPERM-operation-not-permitted-copyfile-when-using-node-14-9-0-or-later-

[Feature] Support dry run in rollout-image

Orb version

0.2.0

What happened

I want to use dry-run for rollout-image command.

Expected behavior

I've patched my inline orb to add dry-run parameter.

commands:
  rollout-image:
    parameters:
      dry-run:
        default: none
        description: |
          Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.
        type: string
    steps:
      - gke/update-kubeconfig-with-credentials:
          cluster: <<parameters.cluster>>
      - run:
          command: >
            DRY_RUN="<< parameters.dry-run >>"
            if [ -n "<<parameters.namespace>>" ]; then
              set -- "$@" --namespace="<<parameters.namespace>>"
            fi
            set -- "$@" "--dry-run=${DRY_RUN}"
            kubectl set image deployment <<parameters.deployment>>
            <<parameters.container>>=<<parameters.image>>:<<parameters.tag>> "$@"

No way to define the manifests to deploy

Orb version:

1.4.0

What happened:

I tried to follow the instructions here: https://circleci.com/developer/orbs/orb/circleci/gcp-gke
and here: https://circleci.com/blog/simplifying-your-ci-cd-build-pipeline-to-gke-with-circleci-orbs/

But looks like there is no way to define the manifest files for the deployment.

Expected behavior:

In Kubernetes, manifest files are used to define the deployment, related configs etc. I'd expect to be able to define them or the folder leading to them in order to perform the deploy. However, to my understanding there is no way to do that.

I would expect to be able to define the manifests and the latest image to deploy among other potentially changed configurations.

Additional Information:

due to this, I don't understand how this orb is supposed to be used in the first place. Maybe a better tutorial would be also needed.

Switch to using gke-gcloud-auth-plugin to prevent build failures when the next version of k8s releases.

Describe Request:

Switch to using gke-gcloud-auth-plugin to prevent build failures when the next version of k8s releases.

Examples:

Running the update-kubeconfig-with-credentials command results in the following bright red warning:

CRITICAL: ACTION REQUIRED: gke-gcloud-auth-plugin, which is needed for continued use of kubectl, was not found or is not executable. Install gke-gcloud-auth-plugin for use with kubectl by following https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke

Supporting Documentation Links:

https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke

whatsapp

Orb version:

What happened:

Expected behavior:

Additional Information:

Wrong parameters for k8s deploy

I think the step with setting new image on k8s is doing sth wrong. Its line 37 in Orb Source: kubectl set image deployment <<parameters.deployment>> <<parameters.container>>=<<parameters.image>> If it is like that k8s can't pull image from registry. In think kubectl set image deployment <<parameters.deployment>> <<parameters.container>>=<<parameters.registry-url>>/<<parameters.google-project-id>>/<<parameters.image>>:<parameters:tag> should work.

I've checked and solution from above works.

GOOGLE_COMPUTE_REGION is ignored on "update-kubeconfig-with-credentials"

Orb version: 1.4.0

What happened:

Environment variable $GOOGLE_COMPUTE_REGION is ignored, and command update-kubeconfig-with-credentials fails for asia-northeast1 cluster.

e.g.

jobs:
  gke-test:
    environment:
      GOOGLE_COMPUTE_REGION: asia-northeast1
      GOOGLE_PROJECT_ID: my_project_name
    machine:
      image: ubuntu-2004:202111-01
    working_directory: ~/repo
    steps:
      - gcp-gke/update-kubeconfig-with-credentials:
          cluster: my-cluster-name
          install-kubectl: true
          perform-login: true

Expected behavior:

kubeconfig update success

Additional Information:

It succeeds by specifying region in cluster name
cluster: "my-cluster-name --region=asia-northeast1"

Example build fails with docker image creation issue

Orb version:

circleci/[email protected]

What happened:

When running your example script the "Build Docker image for GCR" step is failing with the following error:
Status: Downloaded newer image for nginx:1.17
---> 9beeba249f3e
Step 2/2 : COPY ./build/ /usr/share/nginx/html
COPY failed: stat /var/lib/docker/tmp/docker-builder208843034/build: no such file or directory

Exited with code exit status 1
CircleCI received exit code 1

Expected behavior:

Build completion and deployment to GKE cluster

Additional Information:

CircleCI project configuration:

  1. CircleCI Organization Setting > Security > Allow Uncertified Orbs: yes
  2. CircleCI Project Settings > Advanced > Enable dynamic config using setup workflows
  3. CircleCI Project Settings > Environment Variables: GCLOUD_SERVICE_KEY, GOOGLE_COMPUTE_ZONE,GOOGLE_PROJECT_ID
  4. CircleCI Project Settings > Environment Variables: Any .env.local environment variables (e.g. API keys)

config.yml used:
version: 2.1
orbs:
gke: circleci/[email protected] # Google GKE ork for GKE deploy target

workflows:
main:
jobs:
- gke/publish-and-rollout-image:
cluster: myproject0008756324-net-dev-gke
deployment: myproject-deployment
container: myproject-container
image: myproject
tag: "$CIRCLE_SHA1"

cluster is running:
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
myproject0008756324-net-dev-gke us-central1-c 1.20.8-gke.700 12.12.123.12 g1-small 1.20.8-gke.700 3 RUNNING

deployment is available on cluster:
NAME READY UP-TO-DATE AVAILABLE AGE
myproject-deployment 2/2 2 2 12m

perform-login fails due to missing region that is set in env variable

Orb version:

1.4.0

What happened:

Step Update kubeconfig with cluster credentials failed to following error:

#!/bin/bash -eo pipefail
gcloud container clusters get-credentials my-cluster

ERROR: (gcloud.container.clusters.get-credentials) One of [--zone, --region] must be supplied: Please specify location.

Exited with code exit status 1
CircleCI received exit code 1

when running with following config:

      - gcp-gke/update-kubeconfig-with-credentials:
          cluster: my-cluster
          perform-login: true

and GOOGLE_COMPUTE_REGION environment variable in place

Expected behavior:

It should work. I provide the GOOGLE_COMPUTE_REGION as an environment variable.

Additional Information:

Build failing on CircleCI

Orb version

1.0.4 and 1.0.3

What happened

Build fails on CircleCI with the following error:

#!/bin/sh -eo pipefail
# ERROR IN CONFIG FILE:
# [#/orbs/gcr] 0 subschemas matched instead of one
# 1. [#/orbs/gcr] expected type: String, found: Mapping

Full output: error.txt

Expected behavior

The Build should work

create/delete namespace feature

Hello, thanks for the orb! Do you have plans to add create/delete namespace commands? That would be useful in tests as we are exploring to run tests on a remote GKE cluster where PR commits could be tested in separate namespaces.
For now I am planning to do the setup myself but it would be nice to see it added here too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.