Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

spaceonfire/docker-k8s-deploy-tools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-deploy-tools

CI/CD deployment tools for Kubernetes

Docker Image

This alpine-based docker image contains next tools:

  • kubectl - Kubernetes CLI
  • oc - OpenShift CLI
  • istioctl - Istio cli
  • gettext - so you can use envsubst to substitute environment variables in your CI/CD pipeline

Examples

Why should I use envsubst? You should never put secrets into your version control, so you might want to keep them in secret variables in your CI/CD system. You can use envsubst to substituted them correctly in your templates.

A CI/CD system usually sets a bunch of variables to the build environment. Below I'll show an example of GitLab CI variables set in the build environment.

  • CI_PROJECT_NAME: my_awesome_project
  • CI_BUILD_REF_SLUG: f1234d

Your app.yaml could look similar the one below:

...
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    labels:
      app: ${CI_PROJECT_NAME}
    name: sample
  spec:
    replicas: 1
    selector:
      app: ${CI_PROJECT_NAME}
      deployment: ${CI_BUILD_REF_SLUG}
...

After cat app.yaml | envsubst > app.yaml you'll notice the variables have been replaced with their actual values:

...
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    labels:
      app: my_awesome_project
    name: sample
  spec:
    replicas: 1
    selector:
      app: my_awesome_project
      deployment: f1234d
...

GitLab CI example

Below a sample job in an .gitlab-ci.yml file:

deploy:
  image: spaceonfire/k8s-deploy-tools
  stage: deploy
  before_script:
    - oc login "$KUBE_URL" --token="$KUBE_TOKEN" --insecure-skip-tls-verify
    - oc project "$KUBE_NAMESPACE" 2> /dev/null || oc new-project "$KUBE_NAMESPACE"
  script:
    - cat app.yaml | envsubst > app.yaml
    - oc apply -f app.yaml

About

Alpine docker image with kubectl, oc (OpenShift CLI), istioctl and envsubst for use in CI/CD pipelines

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 100.0%