148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}
Setting the EnvironmentChapter 8 ■ Using Rolling UpdatesCreate an Amazon EC2 instance based on the Amazon Linux AMI. Obtain the public IP of the instance andSSH log in to the instance:ssh -i "docker.pem" ec2-user@54.87.191.230Create a Kubernetes cluster using an AWS CloudFormation consisting of a single controller and threeworker nodes running CoreOS, as shown in Figure 8-2.Figure 8-2. CloudFormation EC2 instancesAfter starting the cluster and setting up an A record for the controller instance IP address in the publicDNS name for the CloudFormation, SSH log in to the controller instance:ssh -i "kubernetes-coreos.pem" core@52.205.169.82The controller CoreOS instance is logged in as shown in Figure 8-3.Figure 8-3. SSH logging into the controller instanceInstall kubectl binaries and list the nodes:./kubectl get nodesThe single controller node and the three worker nodes are listed as shown in Figure 8-4.173
Chapter 8 ■ Using Rolling UpdatesFigure 8-4. Listing the nodesThe kubectl rolling-update command is used to perform a rolling update. The syntax for therolling-update command is as follows.kubectl rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_CONTAINER_IMAGE | -f NEW_CONTROLLER_SPEC)The old container name is required to be specified, and if a new controller name is to be assigned tothe updated RC, a new controller name may be specified. Either a new container image or a new containerspecification must be specified as a command parameter. Next, we shall discuss performing a rolling updateusing each of the methods; a new container image and a new controller specification.Rolling Update with an RC Definition FileIn this section we’ll discuss the rolling update of an existing replication controller by providing an RCdefinition file to the kubectl rolling-update command. The following requirements apply for rollingupdatingan RC.1. The new replication controller must be in the same namespace.2. The new replication controller name in the definition file must not be the sameas the existing replication controller being updated.3. The new replication controller must specify at least one matching key with anonequal value in the selector field.First, create a replication controller to be updated. The following RC definition file mysql.yaml createsan RC called mysql and specifies three replicas. Create a definition file mysql.yaml in a vi editor:sudo vi mysql.yamlCopy the following source code to the definition file:---apiVersion: v1kind: ReplicationControllermetadata:name: mysqllabels:app: mysql-app174
- Page 137 and 138: Chapter 5 ■ Using the Tectonic Co
- Page 139 and 140: Chapter 5 ■ Using the Tectonic Co
- Page 141 and 142: Chapter 5 ■ Using the Tectonic Co
- Page 143 and 144: Chapter 5 ■ Using the Tectonic Co
- Page 145 and 146: Chapter 5 ■ Using the Tectonic Co
- Page 147 and 148: Chapter 5 ■ Using the Tectonic Co
- Page 149 and 150: Chapter 5 ■ Using the Tectonic Co
- Page 151 and 152: Chapter 6 ■ Using VolumesPodDocke
- Page 153 and 154: Chapter 6 ■ Using VolumesObtain t
- Page 155 and 156: Chapter 6 ■ Using VolumesFigure 6
- Page 157 and 158: Chapter 6 ■ Using VolumesThe prec
- Page 159 and 160: Chapter 6 ■ Using VolumesFigure 6
- Page 161 and 162: Chapter 6 ■ Using VolumesFigure 6
- Page 163 and 164: Chapter 6 ■ Using VolumesThe kube
- Page 165 and 166: Chapter 6 ■ Using Volumesvolumes:
- Page 167 and 168: Chapter 6 ■ Using VolumesChange d
- Page 169 and 170: Chapter 7 ■ Using ServicesAnother
- Page 171 and 172: Chapter 7 ■ Using ServicesCreatin
- Page 173 and 174: Chapter 7 ■ Using ServicesSimilar
- Page 175 and 176: Chapter 7 ■ Using ServicesList th
- Page 177 and 178: Chapter 7 ■ Using ServicesFigure
- Page 179 and 180: Chapter 7 ■ Using ServicesInvoke
- Page 181 and 182: Chapter 7 ■ Using ServicesFigure
- Page 183 and 184: Chapter 7 ■ Using ServicesFigure
- Page 185 and 186: Chapter 7 ■ Using ServicesIn addi
- Page 187: Chapter 8 ■ Using Rolling Updates
- Page 191 and 192: Chapter 8 ■ Using Rolling Updates
- Page 193 and 194: Chapter 8 ■ Using Rolling Updates
- Page 195 and 196: Chapter 8 ■ Using Rolling Updates
- Page 197 and 198: Chapter 8 ■ Using Rolling Updates
- Page 199 and 200: Chapter 8 ■ Using Rolling Updates
- Page 201 and 202: Chapter 8 ■ Using Rolling Updates
- Page 203 and 204: Chapter 8 ■ Using Rolling Updates
- Page 205 and 206: Chapter 8 ■ Using Rolling Updates
- Page 207 and 208: Chapter 8 ■ Using Rolling Updates
- Page 209 and 210: Chapter 8 ■ Using Rolling Updates
- Page 211 and 212: Chapter 8 ■ Using Rolling Updates
- Page 213 and 214: Chapter 8 ■ Using Rolling Updates
- Page 215 and 216: Chapter 9 ■ Scheduling Pods on No
- Page 217 and 218: Chapter 9 ■ Scheduling Pods on No
- Page 219 and 220: Chapter 9 ■ Scheduling Pods on No
- Page 221 and 222: Chapter 9 ■ Scheduling Pods on No
- Page 223 and 224: Chapter 9 ■ Scheduling Pods on No
- Page 225 and 226: Chapter 9 ■ Scheduling Pods on No
- Page 227 and 228: Chapter 9 ■ Scheduling Pods on No
- Page 229 and 230: Chapter 9 ■ Scheduling Pods on No
- Page 231 and 232: Chapter 9 ■ Scheduling Pods on No
- Page 233 and 234: Chapter 9 ■ Scheduling Pods on No
- Page 235 and 236: Chapter 9 ■ Scheduling Pods on No
- Page 237 and 238: Chapter 9 ■ Scheduling Pods on No
Chapter 8 ■ Using Rolling Updates
Figure 8-4. Listing the nodes
The kubectl rolling-update command is used to perform a rolling update. The syntax for the
rolling-update command is as follows.
kubectl rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_CONTAINER_
IMAGE | -f NEW_CONTROLLER_SPEC)
The old container name is required to be specified, and if a new controller name is to be assigned to
the updated RC, a new controller name may be specified. Either a new container image or a new container
specification must be specified as a command parameter. Next, we shall discuss performing a rolling update
using each of the methods; a new container image and a new controller specification.
Rolling Update with an RC Definition File
In this section we’ll discuss the rolling update of an existing replication controller by providing an RC
definition file to the kubectl rolling-update command. The following requirements apply for rollingupdating
an RC.
1. The new replication controller must be in the same namespace.
2. The new replication controller name in the definition file must not be the same
as the existing replication controller being updated.
3. The new replication controller must specify at least one matching key with a
nonequal value in the selector field.
First, create a replication controller to be updated. The following RC definition file mysql.yaml creates
an RC called mysql and specifies three replicas. Create a definition file mysql.yaml in a vi editor:
sudo vi mysql.yaml
Copy the following source code to the definition file:
---
apiVersion: v1
kind: ReplicationController
metadata:
name: mysql
labels:
app: mysql-app
174