Kubernetes部署过程遇到的坑

Kubernetes部署过程遇到的坑

1.拉取私有镜像

创建Secret

创建docker仓库secret kubectl create secret docker-registry

harbor-secret secret名称

–namespace=指定命名空间,一定要指定

–docker-server=仓库地址

–docker-username=仓库账号

–docker-password=仓库密码

–docker-email=邮箱

kubectl create secret docker-registry harbor-secret --namespace=scms-cluster --docker-server=harbor.hwyuan.com --docker-username=admin --docker-password=***** --docker-email=****@***.com

部署deployment的container内需增加 imagePullSecrets

harbor-secret secret名称

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-vue-deployment
  labels:
    name: nginx-vue-manager
  namespace: scms-cluster
spec:
  replicas: 1
  selector:
    matchLabels:
        name: nginx-vue-manager
  template:
    metadata:
      labels:
        name: nginx-vue-manager
    spec:
      containers:
        - name: nginx-vue-manager
          image: nginx:latest 
          volumeMounts:
            - mountPath: /etc/nginx/nginx.conf
              subPath: nginx/nginx.conf
              name: nginx-data
            - mountPath: /etc/nginx/ssl/
              subPath: nginx/ssl
              name: nginx-data
            - mountPath: /etc/nginx/conf.d/
              subPath: nginx/conf.d/
              name: nginx-data
            - mountPath: /tmp/temp_dir/
              subPath: nginx/tmp/temp_dir/
              name: nginx-data
            - mountPath: /tmp/cache/
              subPath: nginx/tmp/cache/
              name: nginx-data
            - mountPath: /var/wwwroot/
              subPath: nginx/wwwroot/
              name: nginx-data
          ports:
            - containerPort: 80
            - containerPort: 443
            - containerPort: 8080
      volumes:
        - name: nginx-data
          persistentVolumeClaim:
            claimName: nfs-pvc-nginx
      imagePullSecrets:#增加secret
        - name: harbor-secret

2.NFS权限问题

nfs服务器配置/etc/exports

echo "/home/nfs 10.0.5.*(rw,sync,no_root_squash,insecure)" >> /etc/exports

3.Service映射端口问题

每个端口都需要有一个单独的Name

apiVersion: v1
kind: Service
metadata:
  name: nginx-vue-manager
  namespace: scms-cluster
  labels:
    name: nginx-vue-manager
spec:
  selector:
    name: nginx-vue-manager
  type: NodePort
  ports:
    - name: nginx-80
      protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30002
    - name: nginx-443
      protocol: TCP
      port: 443
      targetPort: 443
      nodePort: 30003
    - name: nginx-8080
      protocol: TCP
      port: 8080
      targetPort: 8080
      nodePort: 30004

4.创建POD的NFS文件无法映射

需要给每个node节点安装nfs

sudo dnf install -y nfs-ultils
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值