Huawei cloud Kubernetes administrator training three Homework

Exercise 1

Deployment by the way, to create a pod use redis mirror. Redis get started by logging kubectl.
Deployment for the name<hwcka-003-1-你的华为云id>

[root@svn ch03]# kubectl create deploy hwcka-003-1-chenjo --image redis:alpine
deployment.apps/hwcka-003-1-chenjo created

[root@svn ch03]# kubectl get po
NAME                                 READY   STATUS    RESTARTS   AGE
hwcka-003-1-chenjo-98498d48c-rbj2n   1/1     Running   0          10s

[root@svn ch03]# kubectl logs -f hwcka-003-1-chenjo-98498d48c-rbj2n
1:C 22 Jul 2019 09:28:12.262 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 22 Jul 2019 09:28:12.262 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 22 Jul 2019 09:28:12.262 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 22 Jul 2019 09:28:12.264 * Running mode=standalone, port=6379.
1:M 22 Jul 2019 09:28:12.264 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 22 Jul 2019 09:28:12.264 # Server initialized
1:M 22 Jul 2019 09:28:12.264 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this is                                                     sue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be re                                                     started after THP is disabled.
1:M 22 Jul 2019 09:28:12.264 * Ready to accept connections

Deployment will complete the command yaml shots, created to upload

// kubectl create deploy hwcka-003-1-chenjo --image redis:alpine --dry-run -o yaml > ex1.yaml
// cat ex1.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: hwcka-003-1-chenjo
  name: hwcka-003-1-chenjo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hwcka-003-1-chenjo
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: hwcka-003-1-chenjo
    spec:
      containers:
      - image: redis:alpine
        name: redis
        resources: {}
status: {}

2. Exercise 2

The command line, create a Deployment, copy number 3, the mirror is nginx: latest. Then scroll to upgrade nginx: 1.9.1.
Deployment for the name<hwcka-003-2-你的华为云id>

[root@svn ch03]# kubectl run hwcka-003-2-chenjo --replicas 3 --image nginx:latest
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/hwcka-003-2-chenjo created

[root@svn ch03]# kubectl rollout history deploy hwcka-003-2-chenjo
deployment.extensions/hwcka-003-2-chenjo
REVISION  CHANGE-CAUSE
1         <none>

[root@svn ch03]# kubectl rollout history deploy hwcka-003-2-chenjo --revision 1
deployment.extensions/hwcka-003-2-chenjo with revision #1
Pod Template:
  Labels:       pod-template-hash=67bd474c9
        run=hwcka-003-2-chenjo
  Containers:
   hwcka-003-2-chenjo:
    Image:      nginx:latest
    Port:       <none>
    Host Port:  <none>
    Environment:        <none>
    Mounts:     <none>
  Volumes:      <none>

[root@svn ch03]#

The complete history yaml and upgrade information capture command used to create Deployment upload

// kubectl run hwcka-003-2-chenjo --replicas 3 --image nginx:latest --dry-run -o yaml > ex2.yaml
// cat ex2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: hwcka-003-2-chenjo
  name: hwcka-003-2-chenjo
spec:
  replicas: 3
  selector:
    matchLabels:
      run: hwcka-003-2-chenjo
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: hwcka-003-2-chenjo
    spec:
      containers:
      - image: nginx:latest
        name: hwcka-003-2-chenjo
        resources: {}
status: {}

Guess you like

Origin www.cnblogs.com/chenjo/p/11227443.html