国基北盛—云计算容器云pass(2.4)平台搭建
容器云平台搭建步骤详情:1.虚拟机配置信息:Master: 内存6G + 处理器 2*2+ 硬盘160G+网卡1(192.168.200.103)Node:内存6G + 处理器 2*2+ 硬盘160G+网卡1(192.168.200.104)2.基础环境:2.1 关闭防火墙+关闭selinux+设置主机名+编写hosts文件Master:[root@localhost ~]# hostnamect
·
容器云平台搭建步骤详情:
1.虚拟机配置信息:
Master: 内存6G + 处理器 2*2 + 硬盘160G + 网卡1(192.168.200.103)
Node: 内存6G + 处理器 2*2 + 硬盘160G + 网卡1(192.168.200.104)
2.基础环境:
2.1 关闭防火墙+关闭selinux+设置主机名+编写hosts文件
Master:
[root@localhost ~]# hostnamectl set-hostname master
[root@localhost ~]# bash
[root@master ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.103 master
192.168.200.104 node
[root@master ~]# scp /etc/hosts node:/etc/hosts
[root@master ~]# systemctl stop firewalld
[root@master ~]# systemctl disable firewalld
[root@master ~]# iptables -F
[root@master ~]# swapoff -a
[root@master ~]# sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
[root@master ~]# setenforce 0
[root@master ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
Node:
[root@localhost ~]# hostnamectl set-hostname node
[root@localhost ~]# bash
[root@node ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.103 master
192.168.200.104 node
[root@node ~]# swapoff -a
[root@node ~]# sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
[root@node ~]# setenforce 0
[root@node ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
[root@node ~]# iptables -F
[root@node ~]# systemctl stop firewalld
[root@node ~]# systemctl disable firewalld
2.2导入镜像+挂载镜像+copy镜像
[root@master ~]# ls
CentOS-7-x86_64-DVD-1804.iso chinaskills_cloud_paas.iso
[root@master ~]# mkdir /opt/centos
[root@master ~]# mount -o loop CentOS-7-x86_64-DVD-1804.iso /opt/centos
[root@master ~]# mount -o loop chinaskills_cloud_paas.iso /mnt /
mount: /dev/loop0 is write-protected, mounting read-only
[root@master ~]# cp -r /mnt/* /opt/
[root@master ~]# umount /mnt/
3.3配置yum源
Master:
[root@master ~]# rm -rf /etc/yum.repos.d/*
[root@master ~]# vim /etc/yum.repos.d/local.repo
[centos]
name=centos
gpgcheck=0
enabled=1
baseurl=file:///opt/centos
[k8s]
name=k8s
gpgcheck=0
enabled=1
baseurl=file:///opt/kubernetes-repo
Node:
[root@node ~]# rm -rf /etc/yum.repos.d/*
[root@node ~]# vim /etc/yum.repos.d/local.repo
[centos]
name=centos
gpgcheck=0
enabled=1
baseurl=ftp://master/centos
[k8s]
name=k8s
gpgcheck=0
enabled=1
baseurl=ftp://master/kubernetes-repo
3.执行脚本顺序:
Master:
[root@master opt]# cd /opt/
[root@master opt]# ./k8s_harbor_install.sh
[root@master opt]# ./k8s_image_push.sh
输入镜像仓库地址(不加http/https): 192.168.200.103
输入镜像仓库用户名: admin
输入镜像仓库用户密码: Harbor12345
您设置的仓库地址为: 192.168.200.103,用户名: admin,密码: xxx
是否确认(Y/N): y
[root@master opt]# ./k8s_master_install.sh
[root@master opt]# scp /opt/k8s_node_install.sh node:/opt/
Node:
[root@node ~]# cd /opt/
[root@node opt]# ./k8s_node_install.sh
输入镜像仓库地址(不加http/https): 192.168.200.103
输入镜像仓库用户名: admin
输入镜像仓库用户密码: Harbor12345
您设置的仓库地址为: 192.168.200.103,用户名: admin,密码: xxx
是否确认(Y/N): y
4.验证:
4.1查看私有仓库:
浏览器通过http://192.168.200.103访问Harbor
此处推荐使用火狐浏览器
4.2 查看集群状态:
[root@master ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
master Ready master 6m25s v1.18.1
node Ready <none> 2m32s v1.18.1
[root@master ~]# kubectl get pod -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-69977df6bf-m6nhm 1/1 Running 0 6m52s
coredns-69977df6bf-wwlvm 1/1 Running 0 6m52s
etcd-master 1/1 Running 0 7m2s
kube-apiserver-master 1/1 Running 0 7m2s
kube-controller-manager-master 1/1 Running 0 7m2s
kube-flannel-ds-65q98 1/1 Running 0 3m18s
kube-flannel-ds-zgfvd 1/1 Running 0 6m18s
kube-proxy-qx76c 1/1 Running 0 6m52s
kube-proxy-tnvkg 1/1 Running 0 3m18s
kube-scheduler-master 1/1 Running 0 7m2s
4.3 访问dashboard界面:
执行完 k8s_master_install.sh 最后出现如下字样
dashboard地址:https://192.168.200.103:30000
登录令牌:Name: dashboard-admin-token-xlhhb
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: dashboard-admin
kubernetes.io/service-account.uid: 261463b6-6d63-406f-9138-6423768cdb4d
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1025 bytes
namespace: 20 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InFiNFRFTWk1MU1GNmlaUTZSVDQ5LTRBWU1uLWVvVUVRWUhFVU9SY0toR2cifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4teGxoaGIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiMjYxNDYzYjYtNmQ2My00MDZmLTkxMzgtNjQyMzc2OGNkYjRkIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmVybmV0ZXMtZGFzaGJvYXJkOmRhc2hib2FyZC1hZG1pbiJ9.eEGH8nIzcVJDl1t5reH6YnUSllfbcMQ-PBgGRJWxysg3yPP9NQjdZ9sapXbE4XWsifIXM-ShBmCuU5df3hNd59CI0LJaGjNeaEwBQoT9W6P1o7R7315F_f_MxetaLiSAy0gg-adMXOzMzt74vEzT_Zpnr_YllPGmrBBXauGPHEMN4TTr8QTj_tvyb0NWnU7UXoP4DOe9McZOcL6YUoTcqTb3ymX8o44k5hmrzhJ_q15xXvsGWfJP7letQf4sJV5vK7zwKFz-yUAUZV4erIRTdM0Y2p7cU369cqiTEindzYuhpJHtKNlNnUaXUxhxfFf0kfjAa_OeJS1k8j9ZXXyaRg
浏览器访问 https://192.168.200.103:30000
登录密码选择token,复制上述token即可
4.4测试:
[root@master ~]# kubectl run test-nginx --image=192.168.200.103/library/nginx:latest
pod/test-nginx created
[root@master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
test-nginx 1/1 Running 0 3s
[root@master ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
test-nginx 1/1 Running 0 9s 10.244.1.4 node <none> <none>
[root@master ~]# curl 10.244.1.4
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
测试成功success!!
更多推荐
已为社区贡献5条内容
所有评论(0)