You will need roughly 2 minutes to read this article.
The public repository for our
codeship/kubectl Docker image can be found here.
With a configured k8s cluster context on your local machine, run the following command in your project directory:
kubectl config view --flatten > kubeconfigdata # add --minify flag to reduce info to current context
We have a Docker container built for taking the plaintext, flattened k8s config file and storing to a CodeShip Pro env file. The
/root/.kube/config path specifies exactly where we want the contents of the
kubeconfigdata securely placed in the
codeship/kubectl container during runtime.
docker run --rm -it -v $(pwd):/files codeship/env-var-helper cp kubeconfigdata:/root/.kube/config k8s-env
Check out the codeship/env-var-helper README for more information.
jet encrypt k8s-env k8s-env.encrypted rm kubeconfigdata k8s-env
## codeship-services.yml kubectl: build: image: codeship/kubectl dockerfile: Dockerfile encrypted_env_file: k8s-env.encrypted
## codeship-steps.yml - name: check response to kubectl config service: kubectl command: kubectl config view #- name: attempt to connect to live k8s cluster # service: kubectl # command: kubectl cluster-info
If you’re still largely unfamiliar with CodeShip Pro, then check out our step-by-step walk-through on issuing kubectl commands in CodeShip Pro.
Contact our support team or post on Stack Overflow using the tag
#codeship. Did you check the status page and changelog?
There are also several code examples and sample projects available for you to get started with.