We are bringing the best of Tectonic to Red Hat OpenShift to build the most secure, hybrid Kubernetes application platform.
Kubernetes can scale applications either statically, based on an explicit count of replicas, or dynamically, adding and removing replicas based on application load.
This tutorial outlines static application scaling in Tectonic:
kubectl
and TectonicIt is assumed that you have a functioning Tectonic cluster to try these changes.
Start by copying the following YAML into a file named cookies.yaml
:
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: cookies
labels:
k8s-app: cookies
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
k8s-app: cookies
template:
metadata:
labels:
k8s-app: cookies
spec:
containers:
- name: cookies-container
image: quay.io/coreos/example-app:v1.0
ports:
- name: http
containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
scheme: HTTP
livenessProbe:
initialDelaySeconds: 30
timeoutSeconds: 1
httpGet:
path: /
port: 80
scheme: HTTP
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
Deploy this file with the following kubectl create
command:
$ kubectl create -f cookies.yaml
deployment "cookies" created
$ kubectl get deployments/cookies
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
cookies 3 3 3 3 18s
Next, use the text editor of your choice to change the replicas
value to 5:
spec:
replicas: 5 # bump from 3 to 5
Apply the changes with kubectl apply
:
$ kubectl apply -f cookies.yaml
deployment "cookies" configured
$ kubectl get deploy/cookies
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
cookies 5 5 5 5 1m
Notice the pod count increases from 3 to 5.
Deployments can be scaled directly on the kubectl
command line with the scale
subcommand. The following command scales the cookies
Deployment back down to 3 replicas.
$ kubectl scale deployments/cookies --replicas=3
deployment "cookies" scaled
$ kubectl get deployments/cookies
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
cookies 3 3 3 3 6m
To control application scale in Tectonic Console, first copy the cookies
Deployment's YAML Manifest given above into the Console's YAML editor to create a new deployment:
cookies
Deployment's Manifest into the editor.cookies
Deployment.You may also use the Tectonic Console to scale a deployment graphically.
To edit a Deployment's Manifest file in the Console, click Deployments beneath Workloads in the menu at left. Click the Deployment to be edited, named cookies in this example. The Deployment detail is shown. Click the YAML tab. The Deployment Manifest is shown.
Change the replicas
count to the desired number of replicas of the Deployment. In this example, the cookies
Deployment is scaled from 3 replicas to 5.
spec:
replicas: 5 # bump from 3 to 5
Click Save Changes to scale the Deployment to the new number of replicas.
Use the Pods tab of a given deployment to track the number of Replicas, and the health of those Pods.