🎉 欢迎访问本站,如有问题欢迎 留言
k8s安装

k8s安装

设置代理

代理安装 在当前shell启用代理

export PROXY_PORT=8118
export PROXY_IP=192.168.15.11
export http_proxy=http://$PROXY_IP:$PROXY_PORT
export HTTP_PROXY=$http_proxy
export https_proxy=$http_proxy
export HTTPS_PROXY=$http_proxy
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com,example.com,192.168.1.11,192.168.1.12,192.168.1.13"

安装docker

systemctl disable iptables-services firewalld
systemctl stop iptables-services firewalld

cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system


curl https://get.docker.com/|sh
systemctl enable docker && systemctl start docker

安装 kubeadm,kubelet,kubectl

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
setenforce 0
yum install -y kubelet kubeadm kubectl
source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc
#journalctl -xeu kubelet

运行 k8s

  1. Initializes cluster master node:
kubeadm init --pod-network-cidr=192.168.0.0/16

如果kubelet启动不起来,查看下日志journalctl -xeu kubelet *. not work with enabled swap
添加下面的配置

echo 'Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"' > /etc/systemd/system/kubelet.service.d/90-local-extras.conf

2.Initialize cluster networking:

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

3.(Optional) Initialize kube-dashboard:

curl -L -s https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml  | kubectl apply -f -

访问: https://127.0.0.1:8443 访问不了,:https://github.com/kubernetes/dashboard/wiki/Access-control 目前(v1.7.1)不支持手动切换语言:可以通过浏览器插件更改https://github.com/kubernetes/dashboard/issues/2240 4.如果是单节点需要允许主节点可部署

安装监控 heapster

kubectl create -f  https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/influxdb.yaml
kubectl create -f  https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/heapster.yaml
kubectl create -f  https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/grafana.yaml
最后更新于