Integration kubernetes with docker private registry
May. 26, 2018•0 likes
0 likes
Be the first to like this
Show More
•1,174 views
views
Total views
0
On Slideshare
0
From embeds
0
Number of embeds
0
Download to read offline
Report
Software
What's the problem when we want to use the private registry in the kubernetes.
We also want to run a Docker-In-Docker Pod to push the private image to that private registry and the kubernetes node will pull the private image to run
Thebasicdockerusage
docker pull nginx:yyy
○ Official Repositories + tag
docker pull hwchiu/xxxx:yyy
○ Username + Image name + tag
That’s for Docker Hub.
You don’t need to worry about the
location of the registry
Docker Hub
Docker pull nginx
Host1
Docker pull
hwchiu/aaa
Host2
Docker knows that you want to pull image from
the docker hub (Implicitly)
Privateregistry
Setup the registry for yourself
For externally-accessible
○ You need to handle the network by
yourself
○ IP address or hostname
○ Use HTTPS by default
For localhost
○ Only accessed from localhost
○ Always trust (HTTP/HTTPS)
ImageAscenario
I want to use the kubernetes to do the
CI/CD of my application.
I want to build the docker image based
on my application in the kubernetes
pod.
I want to run the docker image I build
before
workloads
Run a kubernetes pod(DockerHelper)
○ Build the docker image
○ Push the docker image to private registry
Run another kubernetes pod
○ Based on your own application
In the network view
Make sure hosts can connect to registry
via IP/Hostname
Inthecluster
Run as a Pod in the cluster
Pros:
○ DH pod can access it by hostname
■ Kubernetes service
○ K8S guarantee the running instance of
registry container
Cons:
○ Need to handle the data sync within all
nodes
■ If the new registry runs on different node.
○ The k8s node can’t access it via hostname.
Kubernetes cluster
K8S master
K8S nodeK8S node K8S node
Magic Network
Registry Server
1. Deploy the Register
Server with k8s service.
2. Docker-Helper (Pod)
can use registry.default
to talk (easy)
3. K8s node can’t use
registry.default (not
easy)
Docker Helper
Build/Push my
own docker
image
Registry.default
Kubernetes cluster
K8S master
K8S nodeK8S node K8S node
Magic Network
Registry Server
1. Deploy the Register
Server with k8s service.
2. Docker-Helper (Pod)
can use registry.default
to talk (easy)
3. K8s node can’t use
registry.default (not
easy)
Run own docker
image (can’t use the
registry.default)
Kubernetes cluster
K8S master
K8S nodeK8S node K8S node
Magic Network
Registry Server
1. Sync the data between
all K8S node
Ø Mount external volume
Ø Sync the filesystem
Outofthecluster
Run as a standalone server out of the
cluster
Pros:
○ Node can access it by ip/hostname(DNS)
■ Should consider the SSL
Cons:
○ DH Pod should knows the location of
registry server
■ Use DNS, need dns server (not easy)
■ Use IP, DH Pod show know the IP once server
changes IP.
Kubernetes cluster
K8S master
K8S nodeK8S node K8S node
Magic Network
1. The admin should know
the IP/DNS of the
Register Server
K8S masterRegistry Server
Kubernetes cluster
K8S master
K8S nodeK8S node K8S node
Magic Network
1. The admin should know
the IP/DNS of the
Register Server
2. DH push the image to
Registry Server
K8S masterRegistry Server
Docker Helper
Build/Push my
own docker
image
Kubernetes cluster
K8S master
K8S nodeK8S node K8S node
Magic Network
1. The admin should know
the IP/DNS of the
Register Server
2. DH push the image to
Registry Server
3. Pull the image from the
Registry Server and run
as Pod.
K8S masterRegistry Server
Run own docker
image
Problems
Certificated (we’re not rich)
○ We need to modify the docker config for
each node
○ We also need to modify the docker config
for DH pod
Network
○ Only the out of cluster + DNS seems good
■ I don’t want to handle any DNS by myself
Fornetworking
We run the registry as Pod on K8S
We also run nginx (daemonSet) on
each k8s node.
○ Act as a proxy
○ Forward the packet to registry.default
Assume the docker image is
○ localhost:5566/myapp:master
FortheDockerHelperPod
We runs the pod with
hostnetwork=true
The DH Pod will use the host network
stack.
The DH must build the docker image
name as the form localhost:5566/…