Skip to content

Instantly share code, notes, and snippets.

@flyotlin
Last active August 6, 2022 03:52
Show Gist options
  • Save flyotlin/55b802abf54b7f143d17b03bd4196557 to your computer and use it in GitHub Desktop.
Save flyotlin/55b802abf54b7f143d17b03bd4196557 to your computer and use it in GitHub Desktop.
k8s pull from private registry example
---
// config.json
{
"auths": {
"registry.gitlab.com": {
"auth": "YWRtaW46c2VjcmV0VG9rZW4K"
}
}
}
---
# my-app-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
# image 在 private registry 的位置以及 tag
image: registry.gitlab.com/flyotlin/my-app/my-app:latest
resources:
limits:
memory: "128Mi"
cpu: "500m"
# 讓 private registry authenticate k8s
imagePullSecrets:
- name: regcred
---
# regcred.yaml
apiVersion: v1
kind: Secret
metadata:
name: regcred
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: ewogICAgImF1dGhzIjogewogICAgICAgICJyZWdpc3RyeS5naXRsYWIuY29tIjogewogICAgICAgICAgICAiYXV0aCI6ICJZV1J0YVc0NmMyVmpjbVYwVkc5clpXNEsiCiAgICAgICAgfQogICAgfQp9Cg==
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment