集群环境搭建&&网盘部署
(1) 修改主机名并配置映射
# hostnamectl set-hostname master
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.10 master
192.168.100.11 node
(2) 关闭SELinux和防火墙
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# setenforce 0
# systemctl stop firewalld.service
# systemctl disable firewalld.service
(3) 删除iptables防火墙规则
# iptables -F
# iptables -X
# iptables -Z
# /usr/sbin/iptables-save
(4) 配置yum源
@@master节点
# mkdir /opt/centos
# mount -o loop CentOS-7-x86_64-DVD-2009.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only
# cp -rvf /mnt/* /opt/centos/
# umount /mnt
# mount -o loop kubernetes_v1.2.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only
# cp -rvf /mnt/* /opt/
# umount /mnt
# rm -rf /etc/yum.repos.d/*
# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[k8s]
name=k8s
baseurl=file:///opt/kubernetes-repo
gpgcheck=0
enabled=1
# yum install vsftpd vim -y
# vim /etc/vsftpd/vsftpd.conf
anon_root=/opt
# systemctl restart vsftpd && systemctl enable vsftpd
@@node节点
# rm -rf /etc/yum.repos.d/*
# cat /etc/yum.repos.d/ftp.repo
[centos]
name=centos
baseurl=ftp://master/centos
gpgcheck=0
enabled=1
[k8s]
name=k8s
baseurl=ftp://master/kubernetes-repo
gpgcheck=0
enabled=1
(5) 部署Harbor仓库
执行./k8s_harbor_install.sh
(6) 上传镜像
执行.//k8s_image_push.sh
(7) 部署Kubernetes集群
执行./k8s_master_install.sh
(8) node节点加入集群
执行./k8s_node_install.sh
(9) master节点
执行./k8s_project_install.sh
owncloud网盘
[root@master ~]# cat owncloud-pvc.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: owncloud-pv
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 5Gi
hostPath:
path: /data/owncloud
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: owncloud-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
[root@master ~]# kubectl apply -f owncloud-pvc.yaml
[root@master ~]# cat owncloud-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: owncloud-config
data:
OWNCLOUD_ADMIN_USERNAME: “admin”
OWNCLOUD_ADMIN_PASSWORD: “123456”
[root@master ~]# kubectl apply -f owncloud-configmap.yaml
[root@master ~]# echo 123456 | base64
[root@master ~]# cat owncloud-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: owncloud-db-password
type: Opaque
data:
password: MTIzNDU2Cg==
[root@master ~]# kubectl apply -f owncloud-secret.yaml
[root@master ~]# cat owncloud-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: owncloud-deployment
spec:
replicas: 1
selector:
matchLabels:
app: owncloud
template:
metadata:
labels:
app: owncloud
spec:
containers:
- name: owncloud
image: 192.168.100.10/library/owncloud:latest
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: owncloud-config
env:
- name: OWNCLOUD_DB_PASSWORD
valueFrom:
secretKeyRef:
name: owncloud-db-password
key: password
ports:
- containerPort: 80
volumeMounts:
- name: owncloud-pv
mountPath: /var/www/html
volumes:
- name: owncloud-pv
persistentVolumeClaim:
claimName: owncloud-pvc
[root@master ~]# kubectl apply -f owncloud-deploy.yaml
[root@master ~]# cat owncloud-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: owncloud-service
spec:
selector:
app: owncloud
ports:
- name: http
port: 80
type: NodePort
[root@master ~]# kubectl apply -f .
[root@master ~]# kubectl get secrets
[root@master ~]# kubectl get pvc
[root@master ~]# kubectl get pod -owide
- 点赞
- 收藏
- 关注作者
评论(0)