Skip to content

Instantly share code, notes, and snippets.

@arsham
Created January 24, 2019 13:29
Show Gist options
  • Save arsham/e692de6f6850d5da79660afbe84215f9 to your computer and use it in GitHub Desktop.
Save arsham/e692de6f6850d5da79660afbe84215f9 to your computer and use it in GitHub Desktop.
Login to #docker hub in #kubernetes
docker login
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: registrypullsecret
data:
.dockerconfigjson: "$(cat ~/.docker/config.json | base64 | tr -d '\n')"
type: kubernetes.io/dockerconfigjson
EOF
# To test:
cat <<EOF | kubectl create -f -
apiVersion: v1
kind: Pod
metadata:
name: logintest
spec:
containers:
- name: logintest
image: vervesearch/blinds:latest
imagePullPolicy: Always
command: [ "echo", "SUCCESS" ]
imagePullSecrets:
- name: registrypullsecret
EOF
kubectl logs logintest
kubectl delete po logintest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment