Codefresh Kubernetes Integration

Easily add Kubernetes Clusters in Codefresh

Setup

Note

The “administrator” permission on Codefresh is required to carry out these steps. Ask your Codefresh administrator to grant these permissions on the collaborators page on Codefresh or to carry out the following steps on your behalf.

Login

Login to Codefresh and navigate to the Kubernetes Integration under account settings.

Add Cluster

Click “Add Provider” and select the relevant cloud platform.

Add New Kubernetes Provider to Codefresh

Then click “Add Cluster”. For kops based clusters, select the “Custom Providers” option.

Add Cluster

Next, you’ll be presented a form. In Geodesic Overview we provide a script to make this integration a little bit easier. Run the codefresh-settings script to output all the necessary information you need in order to setup the Kubernetes integration.

Enter the outputs of the script into the form and click save.

Note

We recommend naming the configuration after the cluster name (e.g. us-west-2-staging-example-com).

Enter Kubernetes Credentials

Enter Kubernetes API Details

Read More

The complete docs for configuring Codefresh with Kubernetes can be found on their documentation portal.

Usage

Once you’ve setup the Kubernetes integration with Codefresh, you can leverage it in your codefresh.yaml pipelines by setting the KUBE_CONTEXT environment variable to the name of the connection.

For example, here’s how you could create a namespace in a build step by using the cloudposse/build-harness container.

create_namespace:
  title: Create an Example Namespace
  image: cloudposse/build-harness:0.5.4
  environment:
    - KUBE_CONTEXT=us-west-2-staging-example-com
  commands:
    - "kubectl create namespace example"