美文网首页Kubernets
2.kubernetes 之kubeadmin部署环境02

2.kubernetes 之kubeadmin部署环境02

作者: 条子在洗澡 | 来源:发表于2019-03-30 11:31 被阅读11次

    一些基本配置

    配置KUBECONFIG变量

    #配置命令补全
    yum install -y bash-completion
    echo 'source <(kubectl completion bash)' >> /etc/profile
    source /etc/profile
    
    #配置KUBECONFIG变量
    echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile
    source /etc/profile
    
    

    部署Heapster,master和node节点都要

    docker pull hub.c.163.com/xiaopal/heapster-amd64:v1.5.3
    
    #heapster-mod.yaml 文件内容如下
    
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      annotations:
        rbac.authorization.kubernetes.io/autoupdate: "true"
      labels:
        kubernetes.io/bootstrapping: rbac-defaults
      name: system:heapster
    rules:
    - apiGroups:
      - ""
      resources:
      - events
      - namespaces
      - nodes
      - pods
      - nodes/stats
      verbs:
      - create
      - get
      - list
      - watch
    - apiGroups:
      - extensions
      resources:
      - deployments
      verbs:
      - get
      - list
      - watch
    
    #heapster.yaml内容如下
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: heapster
      namespace: kube-system
    
    ---
    kind: ClusterRoleBinding
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
      name: heapster
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: system:heapster
    subjects:
    - kind: ServiceAccount
      name: heapster
      namespace: kube-system
    
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: heapster
      namespace: kube-system
    spec:
      replicas: 1
      selector:
          matchLabels:
            k8s-app: heapster
      template:
        metadata:
          labels:
            task: monitoring
            k8s-app: heapster
        spec:
          serviceAccountName: heapster
          containers:
          - name: heapster
            image: hub.c.163.com/xiaopal/heapster-amd64:v1.5.3
            command:
            - /heapster
            - --source=kubernetes:https://kubernetes.default?useServiceAccount=true&kubeletHttps=true&kubeletPort=10250&insecure=true
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        task: monitoring
        kubernetes.io/cluster-service: 'true'
        kubernetes.io/name: Heapster
      name: heapster
      namespace: kube-system
    spec:
      ports:
      - port: 80
        targetPort: 8082
      selector:
        k8s-app: heapster
    
    

    开始部署heapster

    kubectl apply -f /k8s_images/heapster-mod.yaml
    kubectl apply -f /k8s_images/heapster.yaml
    #查看是否运行
    kubectl cluster-info
    Kubernetes master is running at https://192.168.199.130:6443
    Heapster is running at https://192.168.199.130:6443/api/v1/namespaces/kube-system/services/heapster/proxy
    KubeDNS is running at https://192.168.199.130:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
    
    

    kubectl 命令使用

    #查看系统功能
    [root@k8s-master1 /]#  kubectl get pods -n kube-system 
    NAME                                  READY     STATUS    RESTARTS   AGE
    coredns-78fcdf6894-fknn6              1/1       Running   0          1h
    coredns-78fcdf6894-msrzf              1/1       Running   0          1h
    etcd-k8s-master1                      1/1       Running   0          1h
    kube-apiserver-k8s-master1            1/1       Running   0          1h
    kube-controller-manager-k8s-master1   1/1       Running   0          1h
    kube-flannel-ds-lbb8r                 1/1       Running   0          28m
    kube-flannel-ds-v525s                 1/1       Running   0          26m
    kube-flannel-ds-zrh55                 1/1       Running   0          26m
    kube-proxy-bmtxg                      1/1       Running   0          26m
    kube-proxy-dhzcm                      1/1       Running   0          1h
    kube-proxy-q4m9m                      1/1       Running   0          26m
    kube-scheduler-k8s-master1            1/1       Running   0          1h
    
    #查看集群信息
    kubectl cluster-info
    
    #查看集群版本
    kubectl version
    
    #查看集群api版本
    kubectl api-versions
    
    #查看k8s-node1 节点信息
    kubectl describe node k8s-node1
    
    #查看pod信息
    kubectl top pod [pod_name]
    
    #查看主机资源使用信息
    [root@k8s-master1 /]# kubectl top nodes
    NAME          CPU(cores)   CPU%      MEMORY(bytes)   MEMORY%   
    k8s-master1   546m         13%       2775Mi          35%       
    k8s-node1     105m         2%        2278Mi          29%       
    k8s-node2     123m         3%        2314Mi          30%  
    
    
    
    

    相关文章

      网友评论

        本文标题:2.kubernetes 之kubeadmin部署环境02

        本文链接:https://www.haomeiwen.com/subject/chxdbqtx.html