码迷,mamicode.com
首页 > Web开发 > 详细

kubernetes(八)二进制安装-集群简单验证

时间:2020-03-29 21:28:20      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:The   schedule   ble   image   docke   pps   available   further   his   

验证集群功能(在master节点上执行)

以一个nginx的service和deployment来验证集群功能

  1. 创建启动文件

    mkdir /opt/k8s/yml
    
    cd /opt/k8s/yml
    
    cat > nginx.yml << EOF
    apiVersion: v1
    kind: Service
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      type: NodePort
      selector:
        app: nginx
      ports:
      - name: http
        port: 80
        targetPort: 80
        nodePort: 8080
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      selector:
        matchLabels:
          app: nginx
      replicas: 1
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.9.1
            ports:
            - containerPort: 80
    EOF
     
    
  2. 启动服务

    kubectl create -f nginx.yml
    
    
    • 第一次启动时需要下载k8s.gcr.io/pause:3.1镜像,国内无法直接下载,造成服务无法启动,通过下面操作来解决

      docker pull kubeimage/pause:3.1
      docker tag kubeimage/pause:3.1 k8s.gcr.io/pause:3.1 
      
      
  3. 观察服务启动情况

    
    root@master:/opt/k8s/yml# kubectl get service -o wide
    NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)       AGE   SELECTOR
    kubernetes   ClusterIP   10.254.0.1    <none>        443/TCP       41h   <none>
    nginx        NodePort    10.254.8.25   <none>        80:8080/TCP   30m   app=nginx
    root@master:/opt/k8s/yml# kubectl get pod -o wide
    NAME                                READY   STATUS    RESTARTS   AGE   IP            NODE    NOMINATED NODE   READINESS GATES
    nginx-deployment-56f8998dbc-955gf   1/1     Running   0          30m   172.30.78.2   slave   <none>           <none>
    root@master:/opt/k8s/yml# curl http://192.168.0.114:8080
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
            width: 35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    
    

遇到问题

  1. k8s组件 kube-scheduler服务停掉,造成所有的pod都处于pending状态,没有任何events信息
  2. k8s组件kube-controller-manager服务停掉,造成所有的rs、rc都不创建,对应的deployment中没有任何events信息,NewReplicats

kubernetes(八)二进制安装-集群简单验证

标签:The   schedule   ble   image   docke   pps   available   further   his   

原文地址:https://www.cnblogs.com/gaofeng-henu/p/12594637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!