Tectonic and Kubernetes

Deploying an application on Tectonic

This tutorial will deploy a simple, stateless website for a local bakery called "The Cookie Shop" to illustrate how to:

Deploy a simple application using kubectl run

Deploy the same application using YAML manifests submitted to the cluster with kubectl

Deploy the same application with Tectonic Console

Applications may be deployed on Tectonic clusters either by using Tectonic Console or with the kubectl CLI tool. Likewise, the application can be scaled and monitored either graphically with Console or scriptably on the command line with kubectl.

This tutorial explores three Kubernetes elements: Deployments, Services, and Ingress.

Deployments control replication of Pods across one or more cluster nodes for scale and reliability.

Services provide an abstract way to refer to a set of Pods, and a level 4 route to access them. Services outlive the individual Pods that may be cycled within a Deployment during application upgrades and other migration events, so they are a more durable way to refer to the functions provided by some group of Pods, often those governed by a Deployment. Services usually have an address that resolves only within the cluster.

Ingress provides an external endpoint and level 7 policy to load-balance traffic through a cluster Service, and in turn to a group of Pods – usually grouped by a Deployment.

Configuring kubectl

Acquiring Tectonic configuration and credentials for kubectl

Begin by logging in to Tectonic Console. Console requires an extra security step of acquiring a one-time token in order to download a kubeconfig file containing cluster credentials:

Log in to Tectonic Console at https://my-cluster.example.com

From Tectonic Console, click Tectonic Admin > My Account on the bottom left of the page.

Use kubectl get svc,deploy to review the running services and deployments just created.

The app is now deployed, but not yet available to a browser interface. To expose the service, use the YAML manifests.

First, use kubectl get to view the deployment above as a manifest:

$ kubectl get deployment/simple-deployment -o yaml

The output YAML demonstrates that the kubectl run command created a resource in the cluster (which may be returned as YAML or JSON). These files can be used to create new resources, and may be stored in git, making them easily versionable.

Delete the simple Deployment and Service

Before continuing, remove the Deployment and Service using kubectl delete:

To connect the Service to the containers of the simple-deployment Deployment, the Service targetPort and the Deployment containerPort must match. If targetPort is not specified, it is assumed to match the external port. The targetPort has been specified for clarity in simple-service.yaml.

Simple Ingress

Copy the following into a file named simple-ingress.yaml. This file will be used to create an Ingress resource to act as a local load balancer.

To connect the Ingress to the Service, the Ingress's spec.rules.http.paths.backend.serviceName must match the Service's metadata.name.

Submitting manifests to the API with kubectl

Create the cluster objects specified in the simple-deployment.yaml, simple-service.yaml, and simple-ingress.yaml manifests by passing each file to kubectl create. Check that the resources were created successfully by listing the objects afterwards:

Create simple Ingress

This deploys three replicas of the application. They'll be connected to by a Service, which is then exposed to the internet by the Ingress resource. Visit https://my-cluster.example.com/simple-deployment/ to confirm the application is up and running.

Our simple Cookie Shop application up and running on Tectonic

Deploying an app with Tectonic Console

To deploy using Tectonic Console, copy and paste YAML file content into Tectonic Console to create Deployments, Services, and Ingress.

First, deploy the sample app:

In the console, go to Workloads > Deployments, and click Create Deployment.

Edit the YAML to match the cluster name and domain you chose to replace my-cluster.example.com.

Click Create.

The Console will create the Ingress resource, and display its Overview window. Copy the Host and Path and combine them into a URL. Visit https://my-cluster.example.com/simple-deployment to check your work.

Observing the app in Console

Use Tectonic Console to check the app’s public IP, Service, Deployment, and running Pods.

Go to Routing > Services to monitor the site’s services.

Viewing the Service in the Console

Go to Routing > Ingress and click on the Ingress name to view the Ingress resource.

Viewing the Ingress resource in the Console

Go to Workloads > Deployments and click on the Deployment name to display the Deployment’s configuration, manifest YAML, and Pods.