K8S: Pull an Image from a Private Registry
Pull Image from Github Docker Package Private

Create the Secret

1
kubectl create secret docker-registry <name> \
2
--docker-server=docker.pkg.github.com \
3
--docker-username=<github-username> \
4
--docker-password=<personal-token> \
5
--docker-email=<github-email>
Copied!
1
kubectl create secret docker-registry <name> \
2
--docker-server=docker.pkg.github.com \
3
--docker-username=<github-username> \
4
--docker-password=<personal-token> \
5
--docker-email=<github-email>
6
-o yaml > github-secret.yaml
7
8
# view the content
9
cat github-secret.yaml
10
11
# apply to k8s
12
kubectl apply -f github-secret.yaml
Copied!

Create deployment

pod.yaml
1
apiVersion: v1
2
kind: Pod
3
metadata:
4
name: pod-name
5
spec:
6
containers:
7
- name: name
8
image: docker.pkg.github.com/duyet/<image-name>:latest
9
imagePullSecrets:
10
- name: <name>
Copied!
Apply to k8s
1
kubectl apply -f pod.yaml
Copied!

Reference

Copy link
Edit on GitHub