• 在kubernetes运行一个容器案例


    1. 检查kubernetes 组件是否正常运行。

    [root@c720120 ~]# kubectl get cs
    NAME                 STATUS    MESSAGE              ERROR
    scheduler            Healthy   ok                  
    controller-manager   Healthy   ok                  
    etcd-0               Healthy   {"health": "true"}  
    etcd-1               Healthy   {"health": "true"}  
    etcd-2               Healthy   {"health": "true"} 


    2. 检查kubernetes master状态

    [root@c720120 ~]# kubectl cluster-info
    Kubernetes master is running at https://192.168.20.134:6443
    Heapster is running at https://192.168.20.134:6443/api/v1/namespaces/kube-system/services/heapster/proxy
    KubeDNS is running at https://192.168.20.134:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
    monitoring-grafana is running at https://192.168.20.134:6443/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
    monitoring-influxdb is running at https://192.168.20.134:6443/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy

    To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.


    3. 检查所有节点是否准备好。

    [root@c720120 ~]# kubectl get nodes
    NAME               STATUS     ROLES     AGE       VERSION
    c720120.xiodi.cn   Ready      master    23d       v1.10.3
    c720121.xiodi.cn   Ready      master    23d       v1.10.3
    c720128.xiodi.cn   Ready      <none>    23d       v1.10.3
    c720129.xiodi.cn   Ready      <none>    23d       v1.10.3


    4. 运行一个nginx的容器案例

    [root@c720120 ~]# kubectl run my-first-nginx --image=nginx --replicas=2 --port=80
    deployment.apps "my-first-nginx" created


    5. 查看所有的pods.

    [root@c720120 ~]# kubectl get pods
    NAME                                READY     STATUS    RESTARTS   AGE
    alpine-interactive-669f6844-dxns9   1/1       Running   3          21d
    flask-7bdd449f7f-kj2z9              1/1       Running   1          2d
    my-first-nginx-6c9fb6f56b-f8kxd     1/1       Running   0          52s
    my-first-nginx-6c9fb6f56b-k5vdz     1/1       Running   0          52s
    nginx                               1/1       Running   2          22d


    6. 查看所有的deployment

    [root@c720120 ~]# kubectl get deployment
    NAME                 DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
    alpine-interactive   1         1         1            1           21d
    flask                1         1         1            1           21d
    my-first-nginx       2         2         2            2           3m


    7. 映射端口到外部,让用户能够访问该服务

    [root@c720120 ~]# kubectl expose deployment my-first-nginx --port=80 --type=LoadBalancer
    service "my-first-nginx" exposed


    8. 查看发布的服务

    [root@c720120 ~]# kubectl get services
    NAME             TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
    kubernetes       ClusterIP      10.96.0.1     <none>        443/TCP        23d
    my-first-nginx   LoadBalancer   10.97.75.31   <pending>     80:31158/TCP   3m


    9. 停止应用

    [root@c720120 ~]# kubectl delete deployment my-first-nginx
    deployment.extensions "my-first-nginx" deleted
    [root@c720120 ~]# kubectl delete service my-first-nginx
    service "my-first-nginx" deleted


    10. 可以查看创建的服务详细信息

    [root@c720120 ~]# kubectl describe service my-first-nginx
    Name:                     my-first-nginx
    Namespace:                default
    Labels:                   run=my-first-nginx
    Annotations:              <none>
    Selector:                 run=my-first-nginx
    Type:                     LoadBalancer
    IP:                       10.111.128.100
    Port:                     <unset>  80/TCP
    TargetPort:               80/TCP
    NodePort:                 <unset>  30066/TCP
    Endpoints:                10.244.3.20:80,10.244.4.8:80
    Session Affinity:         None
    External Traffic Policy:  Cluster
    Events:                   <none>


    11. 用浏览器进行校验下服务

    image

  • 相关阅读:
    文件编程---库函数
    linux文件编程----系统调用
    makefile工程管理
    快速上手日期插件laydate
    js判断浏览器类型以及语言
    谷歌支付服务端详细讲解(PHP)
    php中的date和strtotime函数妙用
    本地搭建GitLab
    mysql查询语句常用字段操作函数
    php中签名公钥、私钥(SHA1withRSA签名)以及AES(AES/ECB/PKCS5Padding)加密解密详解
  • 原文地址:https://www.cnblogs.com/zangxueyuan/p/9214426.html
Copyright © 2020-2023  润新知