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

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

Chapter 12 ■ Using Resource QuotasDescribe the quota compute-resource-quotas:./kubectl describe quota compute-resource-quotas --namespace=defaultThe quota description includes the used resources and hard limits. Because we have not yet created anyresource, the Used column values are all 0, as shown in Figure 12-7.Figure 12-7. Describing compute-resource-quotasExceeding Compute Resource QuotasNext, we shall use the resource quotas to limit the use of compute resources in the default namespace.Create an RC definition file mysql.yaml:---apiVersion: v1kind: ReplicationControllermetadata:name: mysql-rclabels:app: mysql-appspec:replicas: 3selector:app: mysql-appdeployment: v1template:metadata:labels:app: mysql-app284

Chapter 12 ■ Using Resource Quotasdeployment: v1spec:containers:-env:-name: MYSQL_ROOT_PASSWORDvalue: mysqlimage: mysqlname: mysqlports:-containerPort: 3306resources:requests:memory: "640Mi"cpu: "500m"limits:memory: "1280Mi"cpu: "2"Create a replication controller with 10 replicas:./kubectl scale rc mysql-rc --replicas=10Next, describe the compute-resource-quotas. The Used column lists the actual used resources. None ofthe used resources exceed the hard limits, as shown in Figure 12-8.Figure 12-8. Used resources do not exceed the hard limits285

Chapter 12 ■ Using Resource Quotas

Describe the quota compute-resource-quotas:

./kubectl describe quota compute-resource-quotas --namespace=default

The quota description includes the used resources and hard limits. Because we have not yet created any

resource, the Used column values are all 0, as shown in Figure 12-7.

Figure 12-7. Describing compute-resource-quotas

Exceeding Compute Resource Quotas

Next, we shall use the resource quotas to limit the use of compute resources in the default namespace.

Create an RC definition file mysql.yaml:

---

apiVersion: v1

kind: ReplicationController

metadata:

name: mysql-rc

labels:

app: mysql-app

spec:

replicas: 3

selector:

app: mysql-app

deployment: v1

template:

metadata:

labels:

app: mysql-app

284

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

Saved successfully!

Ooh no, something went wrong!