yum install -y etcd kubernetes
......
......
Installed:
kubernetes.x86_64 0:1.5.2-0.7.git269f928.el7
Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7 atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8 conntrack-tools.x86_64 0:1.4.4-7.el7
container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 containers-common.x86_64 1:0.1.40-11.el7_8 docker.x86_64 2:1.13.1-208.git7d71120.el7_9
docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9 docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9 kubernetes-client.x86_64 0:1.5.2-0.7.git269f928.el7
kubernetes-master.x86_64 0:1.5.2-0.7.git269f928.el7 kubernetes-node.x86_64 0:1.5.2-0.7.git269f928.el7 libnetfilter_cthelper.x86_64 0:1.0.0-11.el7
libnetfilter_cttimeout.x86_64 0:1.0.0-7.el7 libnetfilter_queue.x86_64 0:1.0.2-2.el7_2 libnl.x86_64 0:1.1.4-3.el7
libxml2-python.x86_64 0:2.9.1-6.el7_9.6 libyaml.x86_64 0:0.1.4-11.el7_0 oci-register-machine.x86_64 1:0-6.git2b44233.el7
oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 oci-umount.x86_64 2:2.5-3.el7 python-backports.x86_64 0:1.0-8.el7
python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-dateutil.noarch 0:1.5-7.el7 python-dmidecode.x86_64 0:3.12.2-4.el7
python-ethtool.x86_64 0:0.8-8.el7 python-inotify.noarch 0:0.9.4-4.el7 python-ipaddress.noarch 0:1.0.16-2.el7
python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 python-setuptools.noarch 0:0.9.8-7.el7 python-six.noarch 0:1.9.0-2.el7
python-syspurpose.x86_64 0:1.24.50-1.el7.centos socat.x86_64 0:1.7.3.2-2.el7 subscription-manager.x86_64 0:1.24.50-1.el7.centos
subscription-manager-rhsm.x86_64 0:1.24.50-1.el7.centos subscription-manager-rhsm-certificates.x86_64 0:1.24.50-1.el7.centos usermode.x86_64 0:1.111-6.el7
yajl.x86_64 0:2.0.4-4.el7
Dependency Updated:
libxml2.x86_64 0:2.9.1-6.el7_9.6
Complete!
查看etcd、kubernetes、docker版本信息
[root@localhost ~]# etcd --version
etcd Version: 3.3.11
Git SHA: 2cf9e51
Go Version: go1.10.3
Go OS/Arch: linux/amd64
[root@localhost ~]# docker --version
Docker version 1.13.1, build 7d71120/1.13.1
[root@localhost ~]# kubectl --version
Kubernetes v1.5.2
[root@localhost ~]# systemctl start etcd
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl start kube-apiserver
[root@localhost ~]# systemctl start kube-controller-manager
[root@localhost ~]# systemctl start kube-scheduler
[root@localhost ~]# systemctl start kubelet
[root@localhost ~]# systemctl start kube-proxy
查看各个服务状态
[root@localhost ~]# systemctl status etcd
[root@localhost ~]# systemctl status docker
[root@localhost ~]# systemctl status kube-apiserver
[root@localhost ~]# systemctl status kube-controller-manager
[root@localhost ~]# systemctl status kube-scheduler
[root@localhost ~]# systemctl status kubelet
[root@localhost ~]# systemctl status kube-proxy
七项服务都已成功启动、至此kubernetes单机版部署完成。
[root@localhost ~]# kubectl get pods --all-namespaces
No resources found.
[root@localhost ~]# kubectl get nodes
NAME STATUS AGE
127.0.0.1 Ready 3m
查看 node 发现 master 变为 Ready➡Successful,代表kubernetes安装成功。
问题一:
# 如果发现如下错误
[root@localhost kubernetes]# kubectl get pods -n ms
The connection to the server localhost:8080 was refused - did you specify the right host or port?
# 采用如下方式解决
vi .bash_profile
#写入
KUBERNETES_MASTER=192.168.163.130:8080
source .bash_profile
安装iptabes、flanneld、ServiceAccount等
#进入cd /etc/kubernetes/
1、首先生成密钥:
openssl genrsa -out /etc/kubernetes/serviceaccount.key 2048
2、编辑/etc/kubenetes/apiserver
添加以下内容:
KUBE_API_ARGS="--service_account_key_file=/etc/kubernetes/serviceaccount.key"
3、再编辑/etc/kubernetes/controller-manager
添加以下内容:
KUBE_CONTROLLER_MANAGER_ARGS="--service_account_private_key_file=/etc/kubernetes/serviceaccount.key"
4、最后无论是哪种解决方式都需要再重启kubernetes服务:
systemctl restart etcd kube-apiserver kube-controller-manager kube-scheduler
yum install flannel
# 查看flannel状态
systemctl status flanneld.service
观察到:
Jan 06 21:39:28 localhost.localdomain flanneld-start[93109]: E0106 21:39:28.242217 93109 network.go:102] failed to retrieve network config: 100: Key not found (/atomic.io) [3945]
Jan 06 21:39:29 localhost.localdomain flanneld-start[93109]: E0106 21:39:29.242966 93109 network.go:102] failed to retrieve network config: 100: Key not found (/atomic.io) [3947]
Jan 06 21:39:30 localhost.localdomain flanneld-start[93109]: E0106 21:39:30.244089 93109 network.go:102] failed to retrieve network config: 100: Key not found (/atomic.io) [3947]
# 设置缓存
etcdctl set /atomic.io/network/config '{"NETWORK":"172.17.0.0/16"}'
# 启动服务
systemctl start flanneld.service
systemctl status flanneld.service
docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
yum install -y *rhsm*
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm
rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem
启动:kubectl apply -f register-center.yaml
删除:kubectl delete -f register-center.yaml
# ------------------- Dashboard Deployment ------------------- #
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
labels:
ms: register-center
name: register-center
namespace: ms
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
ms: register-center
template:
metadata:
labels:
ms: register-center
spec:
containers:
- name: register-center
image: ms-sailfish/register-center-server:v0.0.1
ports:
- containerPort: 8761
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 8761
initialDelaySeconds: 30
timeoutSeconds: 30
---
# ------------------- Dashboard Service ------------------- #
kind: Service
apiVersion: v1
metadata:
labels:
ms: register-center
name: register-center
namespace: ms
spec:
ports:
- port: 8761
targetPort: 8761
selector:
ms: register-center
type: NodePort