基于k8s部署springcloud微服务
基于k8s部署springcloud微服务
·
一、harbor密钥对创建
kubectl create secret docker-registry harborsecret --namespace=default --docker-server=https://hub.kkb.com --docker-username=admin --docker-password=Harbor12345
查看default空间密匙对
kubectl get secret -n default
二、Deployment创建
创建deployment文件: bzf-deployment.yaml
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
创建deployment: kubectl apply -f bzf-deployment.yaml
查看deployment部署:kubectl describe pod bzf-deployment-54d746755c-hbh7c
三、创建service的文件
service-demo.yaml
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
执行service创建: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
————————————————
版权声明:本文为CSDN博主「Hide on jdk」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u012222011/article/details/123671848
更多推荐
已为社区贡献11条内容
所有评论(0)