/docker-kubectl

Containerized kubectl, extended by envsubst

This was based on @wernight`s tool, see https://github.com/wernight/docker-kubectl for more details

We added the envsubst command to allow to have a simplistic templating mechanism:

envsubst replaces shell-like variable expressions with current values of environment variables:

echo '$PWD' | envsubst will result in the same output as echo $PWD

by envsubst in our Jenkins build job, similar to

cat any-k8s-resources/deployment.yml | envsubst | kubectl apply -'

complete example:

node('docker') {
  docker.inside('skylo/kubectl', '-e K8S-DOCKER-IMAGE=skylo/kubectl:1.6.1') {
    // add specific config from jenkins workspace into the correct location for use by kubectl
    sh 'cp .kubeconfig /config/.kube/'
    
    // pre-check if connections works:
    sh 'kubectl cluster-info'
    
    // this allows to replace shell-like variable expression by current environment by envsubs, e.g.
    //    `$K8S-DOCKER-IMAGE`   by   `skylo/kubectl:1.6.1`
    sh 'cat k8s-resources/deployment.yml | envsubst | kubectl apply -'
 }
}

Supported tags and respective Dockerfile links

 * 1.6.1