美文网首页
Centos7安装kubernetes1.7.5

Centos7安装kubernetes1.7.5

作者: 腾蛟紫电 | 来源:发表于2017-12-05 17:32 被阅读0次

    系统环境centos7

    准备

    • 关闭防火墙
    systemctl stop firewalld && systemctl disable firewalld
    
    • 禁用交换内存
    swapoff -a
    
    • 禁用SELinux
    setenforce 0
    

    安装docker

    wget https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-1.12.6-1.el7.centos.x86_64.rpm
    
    yum localinstall -y docker-engine-1.12.6-1.el7.centos.x86_64.rpm
    
    systemctl enable docker && systemctl start docker
    

    安装kubernetes

    设置kubernetes的yum阿里镜像

    cat >> /etc/yum.repos.d/kubernetes.repo <<EOF
    [kubernetes]
    name=Kubernetes
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    enabled=1
    gpgcheck=0
    EOF
    

    拉取k8s相关镜像

    docker pull alleyj/k8s-dns-dnsmasq-nanny-amd64:1.14.4
    docker pull alleyj/k8s-dns-kube-dns-amd64:1.14.4
    docker pull alleyj/k8s-dns-sidecar-amd64:1.14.4
    docker pull alleyj/controller-manager-amd64:v1.7.5
    docker pull alleyj/kube-apiserver-amd64:v1.7.5
    docker pull alleyj/kube-scheduler-amd64:v1.7.5
    docker pull alleyj/kube-proxy-amd64:v1.7.5
    docker pull alleyj/kube-discovery-amd64:1.0
    docker pull alleyj/dnsmasq-metrics-amd64:1.0
    docker pull alleyj/etcd-amd64:3.0.17
    docker pull alleyj/exechealthz-amd64:1.2
    docker pull alleyj/k8s-dns-dnsmasq-nanny-amd64:1.14.1
    docker pull alleyj/k8s-dns-kube-dns-amd64:1.14.1
    docker pull alleyj/k8s-dns-sidecar-amd64:1.14.1
    docker pull alleyj/kube-apiserver-amd64:v1.6.0
    docker pull 4admin2root/kube-controller-manager-amd64:v1.6.0
    docker pull alleyj/kube-proxy-amd64:v1.6.0
    docker pull alleyj/kube-scheduler-amd64:v1.6.0
    docker pull alleyj/pause-amd64:3.0
    

    设置成原来的标签

    docker tag alleyj/k8s-dns-dnsmasq-nanny-amd64:1.14.4 grc.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.4
    docker tag alleyj/k8s-dns-kube-dns-amd64:1.14.4 grc.io/google_containers/k8s-dns-kube-dns-amd64:1.14.4
    docker tag alleyj/k8s-dns-sidecar-amd64:1.14.4 grc.io/google_containers/k8s-dns-sidecar-amd64:1.14.4
    docker tag alleyj/controller-manager-amd64:v1.7.5 grc.io/google_containers/controller-manager-amd64:v1.7.5
    docker tag alleyj/kube-apiserver-amd64:v1.7.5 grc.io/google_containers/kube-apiserver-amd64:v1.7.5
    docker tag alleyj/kube-scheduler-amd64:v1.7.5 grc.io/google_containers/kube-scheduler-amd64:v1.7.5
    docker tag alleyj/kube-proxy-amd64:v1.7.5 grc.io/google_containers/kube-proxy-amd64:v1.7.5
    docker tag alleyj/kube-discovery-amd64:1.0 grc.io/google_containers/kube-discovery-amd64:1.0
    docker tag alleyj/dnsmasq-metrics-amd64:1.0 grc.io/google_containers/dnsmasq-metrics-amd64:1.0
    docker tag alleyj/etcd-amd64:3.0.17 grc.io/google_containers/etcd-amd64:3.0.17
    docker tag alleyj/exechealthz-amd64:1.2 grc.io/google_containers/exechealthz-amd64:1.2
    docker tag alleyj/k8s-dns-dnsmasq-nanny-amd64:1.14.1 grc.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.1
    docker tag alleyj/k8s-dns-kube-dns-amd64:1.14.1 grc.io/google_containers/k8s-dns-kube-dns-amd64:1.14.1
    docker tag alleyj/k8s-dns-sidecar-amd64:1.14.1 grc.io/google_containers/k8s-dns-sidecar-amd64:1.14.1
    docker tag alleyj/kube-apiserver-amd64:v1.6.0 grc.io/google_containers/kube-apiserver-amd64:v1.6.0
    docker tag 4admin2root/kube-controller-manager-amd64:v1.6.0 grc.io/google_containers/kube-controller-manager-amd64:v1.6.0
    docker tag alleyj/kube-proxy-amd64:v1.6.0 grc.io/google_containers/kube-proxy-amd64:v1.6.0
    docker tag alleyj/kube-scheduler-amd64:v1.6.0 grc.io/google_containers/kube-scheduler-amd64:v1.6.0
    docker tag alleyj/pause-amd64:3.0 grc.io/google_containers/pause-amd64:3.0
    

    安装kubeadm

    yum -y install kubectl kubeadm kubelet kubernetes-cni
    
    systemctl enable kubelet && systemctl start kubelet
    

    查看kubelet日志

    journalctl -xue | kubelet
    

    如果发现"cgroupfs" is different from docker cgroup driver: "systemd"的错误则修改/etc/systemd/system/kubelet.service.d/10-kubeadm.conf文件将将“--cgroup-driver=systems”修改成为“--cgroup-driver=cgroupfs”,重新启动kubelet

    cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    

    [Service]
    Environment="KUBELET_KUBECONFIG_ARGS=--kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true"
    Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true"
    Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin"
    Environment="KUBELET_DNS_ARGS=--cluster-dns=10.96.0.10 --cluster-domain=cluster.local"
    Environment="KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt"
    Environment="KUBELET_CADVISOR_ARGS=--cadvisor-port=0"
    Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs"
    ExecStart=
    ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_CADVISOR_ARGS $KUBELET_CGROUP_ARGS $KUBELET_EXTRA_ARGS

    systemctl daemon-reload
    systemctl restart kubelet
    

    Master节点安装

    kubeadm init --kubernetes-version=v1.7.5 --pod-network-cidr=192.168.0.0/16
    

    安装calico网络组件

    kubectl apply -f http://docs.projectcalico.org/v2.4/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
    

    相关文章

      网友评论

          本文标题:Centos7安装kubernetes1.7.5

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