apiVersion: apps/v1
kind: Deployment
metadata:
  name: hm-deployment
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hm
      release: stabel
  template:
    metadata:
      labels:
        app: hm
        release: stabel
        env: test
    spec:
      #nodeName: k8s-master
      containers:
      - name: hm
        image: hub.kkb.com/hm/hm:v1
        imagePullPolicy: IfNotPresent
        ports:
        - name: hm
          containerPort: 8666
      imagePullSecrets:
      - name: harborsecret

apiVersion: v1
kind: Service
metadata:
  name: hm-service
spec:
  type: NodePort
  selector:
    app: hm
    release: stabel
  ports:
  - name: http
    protocol: TCP
    port: 8666
    targetPort: 8666

服务编排好,执行命令

kubectl create secret docker-registry harborsecret --namespace=default --docker-server=https://hub.kkb.com --docker-username=admin --docker-password=Harbor12345

kubectl get secret -n default

kubectl apply -f bzf-deployment.yaml

kubectl describe pod  bzf-deployment-54d746755c-hbh7c

kubectl apply -f service-demo.yaml 

对k8s无法连接harbor私服解决办法

kubectl create secret docker-registry harbor-secret --namespace=default --docker-server=https://hub.kkb.com --docker-username=admin --docker-password=Harbor12345

kubectl get secret -n default

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐