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 QuotasListing the pods cluster-wide indicates that each of the pods was scheduled on a different node, asshown in Figure 12-16.Figure 12-16. Each of the three pods is scheduled on a different node, keeping in consideration the resourceconsumptionNext, create another replication controller from another RC definition file, similar to the first. Thesecond RC is not created, and the error message indicates that the object-quotas quota is exceeded, asshown in Figure 12-17.Figure 12-17. Error message indicates that the object-quotas quota is exceeded forreplicationcontrollersThe hard limit on the number of services is 2. Create one service and create another with a differentname than the default. The second service is not created, and the error message indicates that the objectquotaquota is being exceeded, as shown in Figure 12-18.Figure 12-18. Error message indicates that the object-quotas quota is exceeded for services292

Chapter 12 ■ Using Resource QuotasNext, we shall demonstrate exceeding a ConfigMaps quota. Chapter 11 showed how to createConfigMaps, but I’ll briefly repeat the procedure here. We shall create some ConfigMaps from files in adirectory. The file names must be the same as the ConfigMap key, and the value is the content of the file.Create a directory and set its permissions:sudo mkdir /mysql/envsudo chmod -R 777 /mysql/envcd /mysql/envAdd the five files listed in Table 12-3 to the directory.Table 12-3. Files from Which to Create ConfigMapsFilemysql.root.passwordmysql.databasemysql.usermysql.passwordmysql.allow.empty.passwordContentmysqlmysqldbmysqlmysqlnoCreate five ConfigMaps from the five files../kubectl create configmap mysql-config --from-file=/mysql/env/mysql.root.password./kubectl create configmap mysql-config2 --from-file=/mysql/env/mysql.database./kubectl create configmap mysql-config3 --from-file=/mysql/env/mysql.user./kubectl create configmap mysql-config4 --from-file=/mysql/env/mysql.password./kubectl create configmap mysql-config5 --from-file=/mysql/env/allow.empty.passwordThe five ConfigMaps are created as shown in Figure 12-19.Figure 12-19. Creating ConfigMaps293

Chapter 12 ■ Using Resource Quotas

Next, we shall demonstrate exceeding a ConfigMaps quota. Chapter 11 showed how to create

ConfigMaps, but I’ll briefly repeat the procedure here. We shall create some ConfigMaps from files in a

directory. The file names must be the same as the ConfigMap key, and the value is the content of the file.

Create a directory and set its permissions:

sudo mkdir /mysql/env

sudo chmod -R 777 /mysql/env

cd /mysql/env

Add the five files listed in Table 12-3 to the directory.

Table 12-3. Files from Which to Create ConfigMaps

File

mysql.root.password

mysql.database

mysql.user

mysql.password

mysql.allow.empty.password

Content

mysql

mysqldb

mysql

mysql

no

Create five ConfigMaps from the five files.

./kubectl create configmap mysql-config --from-file=/mysql/env/mysql.root.password

./kubectl create configmap mysql-config2 --from-file=/mysql/env/mysql.database

./kubectl create configmap mysql-config3 --from-file=/mysql/env/mysql.user

./kubectl create configmap mysql-config4 --from-file=/mysql/env/mysql.password

./kubectl create configmap mysql-config5 --from-file=/mysql/env/allow.empty.password

The five ConfigMaps are created as shown in Figure 12-19.

Figure 12-19. Creating ConfigMaps

293

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

Saved successfully!

Ooh no, something went wrong!