You can have your private repository. It is a bit tricky to setup, mainly due to the docker daemon considering any non-local access insecure, but very doable.
There're quite a few way to get images into a cluster, here the ones I can think about:
- (w/o registry): docker save, scp the image to all worker nodes, docker import in each and now you can run pods. Not terribly nice, but is good to know if you need your modified images before you have the registry configured (or during cluster bootstrap)
- upload to a public registry, only ok if a) your cluster can reach it and b) you're ok w/ your images in the wild
- a registry outside the cluster. Configure it as in any docker documentation. Some people prefer this solution, I think a registry is perfect for k8s, especially for scale w/ bittorrent distribution of images
- a registry in cluster configured as in the docs (e.g. w/ a proxy on each node --these days w. Daemonsets, docs should be modified -- this makes docker think all access are local). I don't like this and wouldn't work for me because it relies on socat for external access and that's not available in coreos. With other OS it looks like it should work.
- a registry w/ a service on a NodePort. This is what I use myself:
rm -f registry.pem registry-key.pem kube-registry.tar ca.pem ca-key.pem ca.crt
cp ../../CLUSTER_ASSETS/ssl/ca* .
../../scripts/init-ssl . registry kube-registry
# I don't think this is needed, it is probably my intermedate experiments.
sudo cp ca.pem /usr/local/share/ca-certificates/Kube_Root_CA.crt
sudo update-ca-certificates --verbose
# This is probably not needed
cp -v ca.pem ~/.docker/ca.pem
cp -v registry.pem ~/.docker/cert.pem
cp -v registry-key.pem ~/.docker/key.pem
chmod 0444 ~/.docker/ca.pem
chmod 0444 ~/.docker/cert.pem
chmod 0400 ~/.docker/key.pem
DOCKER_TLS_DIR=/etc/docker/certs.d/w01:32000
# This is for access from outside the cluster
mkdir -pv $DOCKER_TLS_DIR
sudo cp -v ca.pem $DOCKER_TLS_DIR/ca.crt
sudo cp -v registry.pem $DOCKER_TLS_DIR/client.cert
sudo cp -v registry-key.pem $DOCKER_TLS_DIR/client.key
sudo chmod 0444 $DOCKER_TLS_DIR/ca.crt
sudo chmod 0444 $DOCKER_TLS_DIR/client.cert
sudo chmod 0400 $DOCKER_TLS_DIR/client.key
# This is for access inside the cluster.
for m in w01 w02 w03 m01; do
ssh $m sudo mkdir -pv /etc/docker/certs.d/w01:32000
cat ca.pem | ssh $m sudo tee /etc/docker/certs.d/w01:32000/ca.crt
cat registry.pem | ssh $m sudo tee /etc/docker/certs.d/w01:32000/client.cert
cat registry-key.pem | ssh $m sudo tee /etc/docker/certs.d/w01:32000/client.key
kubectl --namespace=kube-system delete secret registry-tls-secret
kubectl --namespace=kube-system create secret generic registry-tls-secret --from-file=registry.pem=registry.pem --from-file=registry-key.pem=registry-key.pem --from-file=ca.pem=ca.pem
kubectl delete --namespace=kube-system svc kube-registry
kubectl create -f registry-svc.yaml
kubectl delete -f registry-rc.yaml
kubectl create -f registry-rc.yaml
The critical part that took me the longest to figure out is where to put the certificates so that docker would use them when talking with the registry. You'll have to adapt a lot of the above, but it should give you an idea.
I'm still working on ingress, because I don't like having to tag and talk to a specific node.
init_ssl is a script I've got from somewhere, you can probably google for it. Nothing special, creates a certificate, a key and sign it w/ the secret key of a certificate authority known to the registry (see the ca.pem we pass around).
For running the registry I use:
kind: ReplicationController
# keep request = limit to keep this container in guaranteed class
- name: REGISTRY_LOG_LEVEL
- name: REGISTRY_HTTP_ADDR
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
- name: REGISTRY_HTTP_TLS_CERTIFICATE
value: /certs/registry.pem
- name: REGISTRY_HTTP_TLS_KEY
value: /certs/registry-key.pem
- name: REGISTRY_HTTP_TLS_CLIENTCAS
value: ' - /certs/ca.pem'
mountPath: /var/lib/registry
secretName: registry-tls-secret
and the service is:
Hope this helps. It was very painful for me.
Maurizio