集群环境搭建&&网盘部署

举报
winnerwhy 发表于 2024/09/26 09:11:05 2024/09/26
【摘要】 (1) 修改主机名并配置映射# hostnamectl set-hostname master# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 l...

(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

【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。