When Tectonic Sandbox installation is complete, the terminal will display instructions for accessing Tectonic Console and
kubectl. Log in to the Console, then use these instructions to deploy your first application.
This tutorial will:
Applications may be deployed on Tectonic clusters both by using Tectonic Console, and by passing a YAML manifest file to the
kubectl create CLI tool. Once deployed, scale and monitor the application using Tectonic Console.
This tutorial will explore three useful Kubernetes concepts,
First, open Tectonic Console to download and configure
Log in to Tectonic Console:
Authenticate and initiate
kubectlbinary for your operating system.
Move the downloaded
kubectl file to
/usr/local/bin (or any other directory in your PATH):
$ chmod +x kubectl $ mv kubectl /usr/local/bin/kubectl
Make the downloaded
kubectl-config file kubectl’s default by copying it to a
.kube directory on your machine:
$ mkdir -p ~/.kube/ # create the directory $ cp path/to/file/kubectl-config $HOME/.kube/config # rename the file and copy it into the directory
$env:KUBECONFIG = "$PWD\provisioning\etc\kubernetes\kubeconfig"
This tutorial will deploy a simple, stateless website for a local bakery called "The Cookie Shop."
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:
The Console will create your deployment, and display its Overview window.
Then, add the service:
The Console will create the service, and display its Overview window.
Then, add the Ingress resource:
The Console will create the Ingress, and display its Overview window. Copy the Host and Path and combine them into a URL. Visit the URL to check your work.
This example will use the simple app deployed above. To create an identical app, first delete the existing app using
$ kubectl delete deploy/simple-deployment svc/simple-service ing/simple-ingress deployment "simple-deployment" deleted service "simple-service" deleted ingress "simple-ingress" deleted
kubectl run to create both a Deployment and a Service object:
$ kubectl run simple-deployment --image=quay.io/coreos/example-app:v1.0 --port=80 --replicas=3 --labels="k8s-app=simple" --expose=true $ kubectl get svc,deploy NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/kubernetes 10.3.0.1 <none> 443/TCP 2h svc/simple-deployment 10.3.105.68 <none> 80/TCP 13s NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/simple-deployment 3 3 3 3 13s
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.
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 may be used to create new resources, and may be stored in git, making them easily versionable.
Before moving on, remove the deployment just created using
$ kubectl delete svc/simple-deployment deploy/simple-deployment
The same application may also be deployed using
kubectl create and YAML files.
First, create three YAML files to define the Deployment, Service, and Ingress objects.
Create a file named
simple-deployment.yaml using the YAML content listed below.
apiVersion: apps/v1beta2 kind: Deployment metadata: name: simple-deployment namespace: default labels: k8s-app: simple spec: replicas: 3 selector: matchLabels: k8s-app: simple template: metadata: labels: k8s-app: simple spec: containers: - name: nginx image: quay.io/coreos/example-app:v1.0 ports: - name: http containerPort: 80
replicas: 3, will create 3 running copies.
Image: quay.io/coreos/example-app:v1.0 defines the container image to run, hosted on Quay.io.
Copy the following into a file named
simple-service.yaml. This file will be used to deploy the service.
kind: Service apiVersion: v1 metadata: name: simple-service namespace: default spec: selector: k8s-app: simple ports: - protocol: TCP port: 80 type: NodePort
To connect the service to the containers run by the deployment, the deployment
containerPort and the service
port must match.
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.
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: simple-ingress namespace: default annotations: kubernetes.io/ingress.class: "tectonic" ingress.kubernetes.io/rewrite-target: / ingress.kubernetes.io/ssl-redirect: "true" ingress.kubernetes.io/use-port-in-redirects: "true" spec: rules: - host: console.tectonicsandbox.com http: paths: - path: /simple-deployment backend: serviceName: simple-service servicePort: 80
To connect the Service to Ingress, the Service
metadata.name and the Ingress
spec.rules.http.paths.backend.serviceName must match.
Instantiate the cluster objects specified in the
simple-ingress manifests by passing the filepaths to
kubectl create. Check that they were created successfully by listing out the objects afterwards:
$ kubectl create -f simple-deployment.yaml deployment "simple-deployment" created $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/simple-deployment 3 3 3 3 7m
$ kubectl create -f simple-service.yaml service "simple-service" created $ kubectl get services -o wide NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR simple-service 10.3.113.190 <pending> 80:30657/TCP 1d k8s-app=simple
$ kubectl create -f simple-ingress.yaml ingress "simple-deployment" created $ kubectl get ingress NAME HOSTS ADDRESS PORTS AGE simple-deployment console.tectonicsandbox.com 80 24s
This will deploy three replicas of the application. They'll be connected by a service, which is then exposed to the internet by the Ingress resource. Visit console.tectonicsandbox.com/simple-deployment/ to confirm that the application is up and running.
Use Tectonic Console to monitor the app’s public IP, Service, Deployment, and related Pods.
Go to Routing > Services to monitor the site’s services.
Go to Routing > Ingress and click on the Ingress name to view the Ingress resource.
Go to Workloads > Deployments and click on the Deployment name to monitor the deployment’s Pods.
The examples above used container images that have been shared publicly. To generate and host your own container images, we suggest using Quay.io or Quay Enterprise. The Quay container registry offers sophisticated access controls, easily automated builds, and automated security scanning, free for public projects.
Substitute your custom image and version (known as a "tag") in the Deployment above, by changing:
containers: - name: nginx image: quay.io/coreos/example-app:v1.0