k8s 访问 自己搭建的私库
1. 创建访问Secret
kubectl create secret docker-registry my-registry-key \
--docker-server=192.168.0.200:30082 \
--docker-username=admin \
--docker-password=123456
2. 拉取镜像的配置
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-boot-demo-deployment
spec:
replicas: 1
selector:
matchLabels:
name: spring-boot-demo
template:
metadata:
labels:
name: spring-boot-demo
spec:
imagePullSecrets:
- name: my-registry-key
containers:
- name: spring-boot-demo
image: 192.168.0.200:30082/java/spring-boot-demo:1.0.2
ports:
- containerPort: 8080
env:
- name: spring_profiles_active
value: production
- name: env_name
value: k8s-env
参考链接:https://kubernetes.io/zh/docs/concepts/containers/images/