148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

marco.cirilli
from marco.cirilli More from this publisher
19.06.2021 Views

Chapter 10 ■ Configuring Compute ResourcesFigure 10-7. The controller node is not schedulableCreating a Pod with Resources SpecifiedIn this section we will create an example pod with a resource request and limit specified for the container.Create a definition file mysql.yaml using the Docker image mysql for a replication controller. Specifycontainer resource request and limit. The same resource type may be specified only once in a list.---apiVersion: v1kind: ReplicationControllermetadata:name: mysql-v1labels:app: mysql-appspec:replicas: 3selector:app: mysql-appdeployment: v1template:metadata:labels:app: mysql-appdeployment: v1spec:containers:-env:-name: MYSQL_ROOT_PASSWORDvalue: mysqlimage: mysqlname: mysql245

Chapter 10 ■ Configuring Compute Resourcesports:-containerPort: 3306resources:requests:memory: "64Mi"cpu: "250m"limits:memory: "128Mi"cpu: "500m"The definition file mysql.yaml is shown in the vi editor in Figure 10-8.Figure 10-8. Replication controller definition file mysql.yamlCreate a replication controller using the definition file:./kubectl create -f mysql.yamlList the cluster-wide pods:./kubectl get pods246

Chapter 10 ■ Configuring Compute Resources

ports:

-

containerPort: 3306

resources:

requests:

memory: "64Mi"

cpu: "250m"

limits:

memory: "128Mi"

cpu: "500m"

The definition file mysql.yaml is shown in the vi editor in Figure 10-8.

Figure 10-8. Replication controller definition file mysql.yaml

Create a replication controller using the definition file:

./kubectl create -f mysql.yaml

List the cluster-wide pods:

./kubectl get pods

246

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!