Commit 77a10532 authored by moha-s's avatar moha-s
Browse files

Update image, script and documentation

parent 9342bb2e
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ This job will deploy manifests to your cluster using Kustomize and set a new ima
    ```yaml
      - remote: 'https://jobs.r2devops.io/latest/kustomize_deploy.yml'
    ```
1. Set the mandatory variables for your job, check [**Variables**](#variables)
1. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)
1. Well done, your job is ready to work ! 😀
@@ -19,7 +20,7 @@ This job will deploy manifests to your cluster using Kustomize and set a new ima

* Job name: `kustomize_deploy`
* Docker image:
[`nekottyo/kustomize-kubeval:latest`](https://hub.docker.com/r/nekottyo/kustomize-kubeval)
[`line/kubectl-kustomize:1.21.1-4.1.3`](https://hub.docker.com/r/line/kubectl-kustomize)
* Default stage: `deploy`
* When: `manual`, only when running on default branch (`$CI_DEFAULT_BRANCH`).  
  To update this behavior, see [job customization](https://r2devops.io/use-the-hub/#global) to override [`rules`](https://docs.gitlab.com/ee/ci/yaml/#rulesif)
@@ -34,11 +35,11 @@ This job will deploy manifests to your cluster using Kustomize and set a new ima
| `PROJECT_ROOT` | path to the root of the project | no | `.`
| `KUBECONFIG` | the config file for kubectl | yes | ` `
| `KUSTOMIZATION_DIR` | the folder that contains the `kustomization.yaml` file | yes | ` `
| `NAMESPACE` | The namespace to use for deployment | yes | `$KUBE_NAMESPACE`
| `DEPLOYMENT_NAME` | name of deployment to use | yes | ` `
| `POD_NAME` | name of the pods to update | yes | ` `
| `IMAGE_NAME` | name of the new image to use | yes | ` `
| `IMAGE_TAG` | the tag to use for the new image | yes | ` `
| `CHANGE_IMAGE` | ability to change image of deployment | no | `true`
| `NAMESPACE` | The namespace to use for deployment | no | `$KUBE_NAMESPACE`
| `POD_NAME` | name of the pods to update | yes, only if `CHANGE_IMAGE` is `true` | ` `
| `IMAGE_NAME` | name of the new image to use | yes, only if `CHANGE_IMAGE` is `true` | `$CI_REGISTRY_IMAGE`
| `IMAGE_TAG` | the tag to use for the new image | yes, only if `CHANGE_IMAGE` is `true` | ` `
| `KUSTOMIZE_OPTIONS` | Additional options for `kubectl` command | no | ` `

### Artifacts
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ icon: ⚙️
maintainer: moha-s
license: Apache-2.0
images:
  nekottyo/kustomize-kubeval:latest
  line/kubectl-kustomize:1.21.1-4.1.3
tools:
labels:
    - GitLab
+15 −8
Original line number Diff line number Diff line
@@ -4,14 +4,16 @@ stages:
  - deploy

kustomize_deploy:
  image: nekottyo/kustomize-kubeval:latest
  image: 
    name: line/kubectl-kustomize:1.21.1-4.1.3
    entrypoint: [""]
  stage: deploy
  variables:
    PROJECT_ROOT: "."
    KUBECONFIG: ""
    CHANGE_IMAGE: "true"
    KUSTOMIZATION_DIR: ""
    NAMESPACE: "$KUBE_NAMESPACE"
    DEPLOYMENT_NAME: ""
    POD_NAME: ""
    IMAGE_NAME: "$CI_REGISTRY_IMAGE"
    IMAGE_TAG: ""
@@ -20,7 +22,8 @@ kustomize_deploy:

  script:
    # Working directory
    - cd $PROJECT_ROOT
    - cd ${PROJECT_ROOT}/${KUSTOMIZATION_DIR}
    # Image tag to use
    - if [ -z ${IMAGE_TAG} ]; then
    -   if [ ! -z ${CI_COMMIT_TAG} ]; then
    -     IMAGE_TAG=${CI_COMMIT_TAG}
@@ -28,13 +31,17 @@ kustomize_deploy:
    -     IMAGE_TAG=${CI_COMMIT_SHA}
    -   fi
    - fi
    # Deploy the cluster
    - kubectl apply -k $KUSTOMIZATION_DIR $KUSTOMIZE_OPTIONS >> output.log
    # Set the current namespace
    - if [ "${CHANGE_IMAGE}" = "true" ]; then
    -   kustomize edit set image ${POD_NAME}=${IMAGE_NAME}:${IMAGE_TAG} | tee -a ../output.log
    - fi
    # Set the namespace
    - kubectl config set-context --current --namespace=$NAMESPACE
    # Set new image
    - kubectl set image deployment/$DEPLOYMENT_NAME ${POD_NAME}=${IMAGE_NAME}:${IMAGE_TAG} >> output.log
    # Deploy
    - kubectl apply -k . $KUSTOMIZE_OPTIONS | tee -a ../output.log


  environment:
      name: ${CI_COMMIT_REF_SLUG}

  artifacts:
    expose_as: "Kustomize job output"