zoukankan      html  css  js  c++  java
  • 华为云 Kubernetes 管理员实训 三 课后作业

    Exercise 1

    通过Deployment方式,使用redis镜像创建一个pod。通过kubectl获得redis启动日志。
    Deployment的名称为<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完整yaml截图上传

    // 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

    通过命令行,创建一个Deployment,副本数为3,镜像为nginx:latest。然后滚动升级到nginx:1.9.1。
    Deployment的名称为<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]#
    
    

    将所用命令、创建Deployment的完整yaml和升级历史信息截图上传

    // 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: {}
    
    
  • 相关阅读:
    2015.07.20MapReducer源码解析(笔记)
    Hive(笔记)
    HDFS入门(1)
    Zookepper(2015.08.16笔记)
    USB_ModeSwitch 介绍(转)
    Perl 模块 Getopt::Std 和 Getopt::Long
    在linux下设置开机自动启动程序的方法
    gcc Makefile 入门
    Linuxexec函数族及system函数
    signal(SIGHUP, SIG_IGN)的含义
  • 原文地址:https://www.cnblogs.com/chenjo/p/11227443.html
Copyright © 2011-2022 走看看