zoukankan      html  css  js  c++  java
  • kubernetes云平台管理实战: 故障自愈实战(四)

    一、创建实验文件

    [root@k8s-master ~]# cat myweb-rc.yml 
    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: myweb
    spec:
      replicas: 3
      selector:
        app: myweb
      template:
        metadata:
          labels:
            app: myweb
        spec:
          containers:
          - name: nginx
            image: 10.0.128.0:5000/nginx:latest
            ports:
            - containerPort: 80

    二、故障自愈实战

    1、创建前pod状态查看

    [root@k8s-master ~]# kubectl get pod -o wide
    NAME          READY     STATUS    RESTARTS   AGE       IP            NODE
    nginx         1/1       Running   0          1h        172.16.10.2   k8s-node1
    nginx2        1/1       Running   0          19m       172.16.48.2   k8s-node2
    

    2、创建rc并查看状态

    [root@k8s-master ~]# kubectl create -f myweb-rc.yml 
    replicationcontroller "myweb" created
    [root@k8s-master ~]# kubectl get pod -o wide
    NAME          READY     STATUS    RESTARTS   AGE       IP            NODE
    myweb-9rmf4   1/1       Running   0          30s       172.16.10.3   k8s-node1
    myweb-stgrj   1/1       Running   0          30s       172.16.48.4   k8s-node2
    myweb-vhnph   1/1       Running   0          30s       172.16.48.3   k8s-node2
    nginx         1/1       Running   0          1h        172.16.10.2   k8s-node1
    nginx2        1/1       Running   0          19m       172.16.48.2   k8s-node2
    

    3、故障自愈(多次删除自动新启动容器)

    [root@k8s-master ~]# kubectl delete pods myweb-9rmf4
    pod "myweb-9rmf4" deleted
    [root@k8s-master ~]# kubectl get pod -o wide
    NAME          READY     STATUS              RESTARTS   AGE       IP            NODE
    myweb-0b1wf   0/1       ContainerCreating   0          3s        <none>        k8s-node1
    myweb-stgrj   1/1       Running             0          1m        172.16.48.4   k8s-node2
    myweb-vhnph   1/1       Running             0          1m        172.16.48.3   k8s-node2
    nginx         1/1       Running             0          1h        172.16.10.2   k8s-node1
    nginx2        1/1       Running             0          20m       172.16.48.2   k8s-node2
    [root@k8s-master ~]# kubectl delete pods myweb-stgrj
    pod "myweb-stgrj" deleted
    [root@k8s-master ~]# kubectl get pod
    NAME          READY     STATUS    RESTARTS   AGE
    myweb-0b1wf   1/1       Running   0          53s
    myweb-nwzfp   1/1       Running   0          6s
    myweb-vhnph   1/1       Running   0          2m
    nginx         1/1       Running   0          1h
    nginx2        1/1       Running   0          21m
  • 相关阅读:
    文件上传按钮样式定制
    消除2个按钮之间1px细节引起的冲突
    css 实用代码汇总
    除掉inline-block 间距
    SQL Server 创建索引的 5 种方法
    百度API从经纬度坐标到地址的转换服务
    百度地图API简单应用——1.根据地址查询经纬度
    极光API推送 (v3 版本)
    简单快捷地测试 JPush API
    使用极光推送(www.jpush.cn)向安卓手机推送消息【服务端向客户端主送推送】C#语言
  • 原文地址:https://www.cnblogs.com/luoahong/p/10299926.html
Copyright © 2011-2022 走看看