• k8s的安装


    1:修改IP地址、主机名和host解析
    10.0.0.11  k8s-master
    10.0.0.12  k8s-node-1
    10.0.0.13  k8s-node-2
    
    2:所有节点安装docker-1.12.6-68
    yum localinstall docker-common-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm -y
    yum localinstall docker-client-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm -y
    yum localinstall docker-1.12.6-71.git3e8e77d.el7.centos.x86_64.rpm -y
    
    3:master节点安装etcd
    yum install etcd -y
    vim /etc/etcd/etcd.conf
    6行:ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
    21行:ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.11:2379"
     
    systemctl start etcd.service
    systemctl enable etcd.service
     
    etcdctl set testdir/testkey0 0
    etcdctl get testdir/testkey0
    etcdctl -C http://10.0.0.11:2379 cluster-health
    4:master节点安装kubernetes
    yum install kubernetes-master.x86_64 -y
    vim /etc/kubernetes/apiserver 
    8行:  KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
    11行:KUBE_API_PORT="--port=8080"
    17行:KUBE_ETCD_SERVERS="--etcd-servers=http://10.0.0.11:2379"
    23行:KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
    vim /etc/kubernetes/config
    22行:KUBE_MASTER="--master=http://10.0.0.11:8080"
    systemctl enable kube-apiserver.service
    systemctl restart kube-apiserver.service
    systemctl enable kube-controller-manager.service
    systemctl restart kube-controller-manager.service
    systemctl enable kube-scheduler.service
    systemctl restart kube-scheduler.service
    5:node节点安装kubernetes
    yum install kubernetes-node.x86_64 -y
    vim /etc/kubernetes/config 
    22行:KUBE_MASTER="--master=http://10.0.0.11:8080"
    vim /etc/kubernetes/kubelet
    5行:KUBELET_ADDRESS="--address=0.0.0.0"
    8行:KUBELET_PORT="--port=10250"
    11行:KUBELET_HOSTNAME="--hostname-override=10.0.0.12"
    14行:KUBELET_API_SERVER="--api-servers=http://10.0.0.11:8080"
    
    systemctl enable kubelet.service
    systemctl start kubelet.service
    systemctl enable kube-proxy.service
    systemctl start kube-proxy.service
    

      

    6:所有节点配置flannel网络
    yum install flannel -y
    sed -i 's#http://127.0.0.1:2379#http://10.0.0.11:2379#g' /etc/sysconfig/flanneld
    etcdctl mk /atomic.io/network/config '{ "Network": "172.16.0.0/16" }'
    master节点:
    systemctl enable flanneld.service 
    systemctl start flanneld.service 
    service docker restart
    systemctl restart kube-apiserver.service
    systemctl restart kube-controller-manager.service
    systemctl restart kube-scheduler.service
    node节点:
    systemctl enable flanneld.service 
    systemctl start flanneld.service 
    service docker restart
    systemctl restart kubelet.service
    systemctl restart kube-proxy.service
    

      

    7:配置master为镜像仓库
    #master节点
    vim /etc/sysconfig/docker
    OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --registry-mirror=https://registry.docker-cn.com --insecure-registry=10.0.0.11:5000'
    systemctl restart docker
    docker run -d -p 5000:5000 --restart=always --name registry -v /opt/myregistry:/var/lib/registry  registry
    #node节点
    vim /etc/sysconfig/docker
    OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry=10.0.0.11:5000'
    systemctl restart docker
    

    可以产看一些参数

    [root@oldboy ~]# kubectl get nodes
    NAME        STATUS    AGE
    10.0.0.12   Ready     58m
    10.0.0.13   Ready     58m
    上述代表两个节点正常连接
    

      

    8:开启一个nginx的pod

    cat /kubernetes/k8s_nginx_pod.yaml 
    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
      labels:
        app: web
    spec:
      containers:
        - name: nginx
          image: 10.0.0.11:5000/nginx:1.13
          ports:
            - containerPort: 80
    
    kubectl create -f /kubernetes/k8s_nginx_pod.yaml
    docker load -i pod-infrastructure-latest.tar.gz
    docker tag docker.io/tianyebj/pod-infrastructure:latest 10.0.0.11:5000/pod-infrastructure:latest
    docker push 10.0.0.11:5000/pod-infrastructure:latest
    
    
    在两个节点上:
    vim /etc/kubernetes/kubelet
    KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=10.0.0.11:5000/pod-infrastructure:latest"
    
     systemctl restart kubelet.service
    
    kubectl get pods
    NAME      READY     STATUS    RESTARTS   AGE
    nginx     1/1       Running   0          24m
    
    如果READY出现0/1需要结合kubectl describe pod nginx命令去查看问题
    

      

  • 相关阅读:
    nyoj 117 求逆序数 (归并(merge)排序)
    2018年四川理工学院软件工程考试大纲(软件需求分析)
    2018年四川理工学院软件工程考试大纲(软件计划与可行性研究)
    hdu 1166 敌兵布阵 (线段树、单点更新)
    hdu 1754 I Hate It (线段树、单点更新)(PS:ios::sync_with_stdio(false)可以加快cin、cout的读取写出速度)
    周末手撸管理系统(一)
    drf源码save以及response
    drf框架serializers中ModelSerializer类简化序列化和反序列化操作
    drf框架序列化和返序列化
    django模型中有外键关系的表删除相关设置
  • 原文地址:https://www.cnblogs.com/nshgo/p/11144444.html
Copyright © 2020-2023  润新知