Kubernetes is complex and needs a lot of configuration to run properly. To be able to deploy containerized applications to Kubernetes, developers have to create configuration files, manage logging and tracing, and write their own CI/CD scripts using tools like Jenkins or Drone. Knative takes all this hassle away and combined with the Otomi Container Platform makes it even easier.
Knative helps developers by hiding many of these tasks, simplifying container-based management, and enabling you to concentrate on writing application code. Otomi Container Platform supports Knative out-of-the-box together with all Istio service mesh features. When Otomi Stack is installed on Kubernetes version 1.15.x clusters, you can directly start using Knative. This makes deploying and managing cloud-native applications really easy. Otomi Stack delivers an extra abstraction layer on top of Knative, so you don’t even have to know how to use Knative. Just tell Otomi Stack which container image to run and if you would like to scale to zero or not.
In this post, we’ll explain 2 current supported ways to deploy containers with Otomi Container Platform and Knative. We’ll also take a look at a new feature that will be available in the upcoming new release of Otomi Container Platform: deploying containers with Knative and automated CD.
All Otomi Container Platform features are configured using a simple set of values. In a previous post, we explained how to simply configure ingress for services (also for Knative services).
To deploy your container using Knative, go to the cloud/cluster/team values, and add the following service:
teamConfig: teams: team1: name: team1 services: - name: hello ksvc: image: repository: otomi/helloworld-nodejs tag: 1.1.3
The name of the service will be used for short URLs when the service is configured with a public URL. When the values are committed, the Otomi Container Platform will automatically configure and deploy the Knative service.
Knative offers the ability to scale-to-zero. This means a container can be reduced down to zero replicas when idle and brought back to the required amount of replicas when it is needed. By default, the Otomi Container Platform configures Knative to scale-to-zero. To disable the scale-to-zero feature, add the following annotation to the service:
teamConfig: teams: team1: name: team1 services: - name: hello ksvc: image: repository: otomi/helloworld-nodejs tag: 1.1.3 annotations: # Disable scale to zero with a minScale of 1. autoscaling.knative.dev/minScale: '1'
When a team is added to a Cloud or cluster, the team will be provided with a bearer token of the team service account. With this token, a team can deploy allowed objects to their team namespace. Because Container Platform provides Knative out-of-the-box, teams can also deploy Knative services themselves. Here’s an example of a simple Knative service manifest file:
apiVersion: serving.knative.dev/v1 kind: Service metadata: name: hello namespace: team-team1 spec: template: spec: containers: - image: otomi/helloworld-nodejs:1.1.3 env: - name: VERSION value: "1.1.3"
The next release of our Container Platform will also support automated CD together with Knative. The following values example shows how automated CD can be added to a service:
teamConfig: teams: team1: name: team1 services: - name: hello ksvc: autoCD: tagMatcher: semver semver: ~1.1 image: repository: otomi/helloworld-nodejs tag: 1.1.3
The tagMatcher can be semver, glob or regexp. Flux will sort images based on the selected image filter pattern type. In the example, we use semver tagging. When a new image is pushed, the new image will be automatically deployed. Read more about Flux and tagging pattern types.
In this blog post we have shown 2 options for deploying containers with Knative to an Otomi Container Platform controlled Kubernetes cluster:
With the Otomi Container Platform you’ll get Knative (together with Istio service mesh features) pre-installed and configured. Flux will be available in the next release for automated CD.
Otomi Container Platform values offer an extra abstraction layer, enabling you to use Knative and Istio without the need to dive deep into all the configuration details, enabling you to concentrate on writing amazing applications. The new release of the Otomi Container Platform will also offer a UI to add and edit the values.