What's New

Bringing Continuous Delivery with Codefresh to Kubernetes on IBM Cloud

Share this post:

This post was co-authored with Dan Garfield, VP of Marketing at Codefresh and Full-Stack Developer.  We’re excited to partner with Codefresh and validate their technology on IBM Cloud, providing both customers sets with a consistent user experience and tool set.

As a certified Kubernetes provider, IBM is one of the leaders in hosted and managed Kubernetes. With integrations into Watson, upstream Kubernetes, and options to run bare metal, IBM has been a popular choice for enterprise customers. One of the most critical components of adopting Kubernetes is providing a control plane to engineers so they can deploy what they need, this is where Codefresh comes in (but we’ll get to that later). To see how Codefresh bring continuous delivery to Kubernetes on IBM Cloud, join the webinar.

IBM Cloud Container Service (ICCS) launched as a managed Kubernetes offering in May 2017 to deliver powerful tools, an intuitive user experience, and built-in security and isolation to enable rapid delivery of applications all while leveraging Cloud Services.  ICCS ensures a completely native user experience with K8s capabilities.  Additionally, IBM is adding capabilities to the container service including simplified cluster management, container security and isolation choices, ability to design your own cluster, leverage other IBM Cloud services (170+ in catalog), and integrated operational tools or support to bring your own tools to ensure operational consistency with other deployments.

Before containers are shipped to a production Kubernetes cluster we need to validate that the container is:

  • Secure
  • Performant
  • Working (unit tests)
  • Functional within the entire application context (integration)

This is where a continuous delivery/continuous deployment pipeline can have a big impact on how effective engineers are. Adopting containers with continuous delivery has lead to staggering stats like this one:

Continuous Delivery and Kubernetes Pipelines Help Teams Deliver Higher-Quality Code, Faster

Kubernetes already unlocks a ton of super powers that were all engineering feats in their own right before. Things like failover, high-availability, scalability, microservices, infrastructure as code and so much more. But without pairing with Kubernetes pipelines it’s hard to take advantage. Infrastructure-as-code is great if you can validate it and deliver it like code. Microservices are lovely but without meaningful integration and functional testing, teams can easily get overwhelmed. And without a central control plane for shipping code from individuals into production, it’s easy to get lost.

This is where Codefresh pairs so well with Kubernetes on IBM Cloud. Codefresh is a DevOps platform with Kubernetes pipelines. It integrates with IBM Cloud to make it easier for teams to adopt and deploy containers into production and works with IBM Cloud Container Registry for storing images.

What can Codefresh do?

Codefresh has out-of-the-box steps for working with Kubernetes and other cloud native technologies like Helm. It’s easy to create a pipeline that builds Docker images, deploys them to on-demand environments for testing and validation and then on into production. Codefresh includes dashboards for Kubernetes, Helm, and managing images.

How to setup a Kubernetes Pipeline with Codefresh and IBM Cloud

Today I’ll show you how we’ve integrated Codefresh with IBM Cloud to seamlessly deploy containers to Kubernetes.

Step 1: Create your clusters on IBM Cloud

This is easy to do in the UI. You can create one free cluster and then pick from an inexpensive plan for building something more robust.

Step 2: Configure Kubectl using IBM CLI

This assumes you’ve already installed the IBM CLI and Kubeconfig. Here are the instructions if you still need to do that.

Login to bluemix

  bx login   

Get cluster names

  bx cs clusters

Login to bluemix

  bx cs  cluster-config [cluster name]

Run the generated export command. It will look something like this

export KUBECONFIG=/Users/dan/.bluemix/plugins/container-service/clusters/codefresh_ibm/kube-config-dal13-codefresh_ibm.yml

Step 3: Connect Codefresh to your cluster

Create your Codefresh account if you haven’t done so already. Codefresh SaaS has support for logging in with Github, Bitbucket, or Gitlab. If you’d like to connect to on-prem Git, use Single sign on, or another setup ping us for a free POC and we’ll get you setup.

And click Kubernetes then Add Cluster. Name the cluster whatever you like and then we’ll need to gather the connection info, namely, the Host IP, the certificate, and the token.

Here’s how to get that information using your newly configured Kubectl.

Host IP

export CURRENT_CONTEXT=$(kubectl config current-context) && export CURRENT_CLUSTER=$(kubectl config view -o go-template=”{{\$curr_context := \”$CURRENT_CONTEXT\” }}{{range .contexts}}{{if eq .name \$curr_context}}{{.context.cluster}}{{end}}{{end}}”) && echo $(kubectl config view -o go-template=”{{\$cluster_context := \”$CURRENT_CLUSTER\”}}{{range .clusters}}{{if eq .name \$cluster_context}}{{.cluster.server}}{{end}}{{end}}”)

Certificate

echo $(kubectl get secret -o go-template='{{index .data “ca.crt” }}’ $(kubectl get sa default -o go-template=”{{range .secrets}}{{.name}}{{end}}”))

Token

echo $(kubectl get secret -o go-template='{{index .data “token” }}’ $(kubectl get sa default -o go-template=”{{range .secrets}}{{.name}}{{end}}”))

 Add this into Codefresh and click test. You should see a confirmation like this

Click save, and you’ll be able to see the cluster and node status.

Now that your cluster is connected, we can reference it from any pipeline, deploy services, see what images are running, manage Helm packages and lots, lots, more.

Step 4: Connect your code repository and build an image

Still on Codefresh, click on “Repositories” in the top left menu and “Add Repository.

This will guide you through connecting a repo to Codefresh. You’ll want to bring your Dockerfile with you though there are some limited templates to help you get started. Once you’ve added your repo with your Dockerfile, click build to build your first Docker image.

You’ll see that there is a simple UI to help you add some tests and you have the option to switch to a YAML view of the pipeline to do more advanced configuration.

Step 5: Deploy your first service, and automate the pipeline

Now that we have an image and a cluster, it’s time to get that image deployed and automate the build and deploy steps. Here you have a choice, keep it under version control or manually deploy and update.

Manual Deployment

Now if you save and build, you’ll be able to start deploying to Kubernetes on IBM Cloud!

Optionally, you can click the YAML switch to see how this configuration looks in Codefresh YAML.

 

Step 6 (optional): Invite your team

Now that you’ve setup the cluster and a pipeline, invite your team to your account! They’ll be able to see what you’ve added and create their own pipelines for deployment. You can invite collaborators by clicking here or going to your account settings.

Conclusion

IBM’s easy to use Kubernetes service is really one of the best ways to get started. What we’ve setup today is a basic pipeline that builds and deploys images into Kubernetes using out-of-the box steps. Next, you’ll want to add your testing steps, unit testing, functional testing etc. Taking the pipeline and adding multiple deployment steps can simplify this further by exposing environments for tests.  If you have questions or concerns, engage our team via Slack.  You can register here (https://bxcs-slack-invite.mybluemix.net) and join the discussion in the #questions channel on https://ibm-container-service.slack.com.

As you add testing, think not only of validating your code, but also your infrastructure. Already we’re going to be testing the Docker image, rather than just a code change but we can also test our Kubernetes YAMLs, or use a package manager like Helm to define the entire application stack and test that.

Ultimately, you’ll end up with high-quality applications that ship fast. Learn more about Codefresh today!

Want to see this in action? Watch the webinar.

Program Director, Offering Management, IBM Kubernetes Service & IBM Container Registry

More What's New stories
December 12, 2018

What’s Included in the IBM Cloud Developer Tools Version 2.1.12

We are pleased to announce the latest version of IBM Cloud Developer Tools CLI Version 2.1.12.

Continue reading

December 10, 2018

IBM Cloud and Portworx: Use Kubernetes to Run All Your Data Analytics Workloads

IBM has partnered with Portworx to offer a Kubernetes storage and data management solution for stateful apps that is designed to take advantage of IBM Cloud network-attached block storage as well as new software-defined-storage-enabled bare metal servers.

Continue reading

December 7, 2018

IBM Cloud Functions Adds Support for Node.js 10

IBM Cloud Functions officially supports the latest version of Node.js including included security updates, new features, and performance improvements.

Continue reading