Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A First Look at Kubernetes Integrated Docker for Mac 17.12 Platform
- Install Docker for Mac 17.12 Edge Release on your Mac System
- Kubernetes is only available if you are part of the private beta for Docker for Mac 17.12.
- To access beta builds, you must be signed in within Docker for Mac using your Docker ID.
- If you are participating in the Docker Beta program, you can access the beta for Docker for Mac 17.12 CE. This version includes a standalone Kubernetes server and client, as well as Docker CLI integration.
- To log in with your Docker ID, select whale menu -> Sign in / Create Docker ID from the menu bar.
- You can enable this feature to test deploying your workloads on Kubernetes. The Kubernetes server runs within a Docker container on your Mac, and is only for local testing. When Kubernetes support is enabled, you are able to deploy your workloads, in parallel, on Kubernetes, Swarm, and as standalone containers. Enabling or disabling the Kubernetes server does not affect your other workloads.
- The Kubernetes server runs locally within your Docker instance, is not configurable, and is a single-node cluster. It is provided for development and testing only.
Ajeets-MacBook-Air:~ ajeetraina$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
73997f6c2baa kamoulox/compose-controller "/compose-controller…" 19 minutes ago Up 19 minutes k8s_compose_compose-64c876947c-ngkrw_docker_c73ee838-e06a-11e7-acaa-025000000001_0
27057b9d7d5d gcr.io/google_containers/pause-amd64:3.0 "/pause" 19 minutes ago Up 19 minutes k8s_POD_compose-64c876947c-ngkrw_docker_c73ee838-e06a-11e7-acaa-025000000001_0
d6622ce0b759 gcr.io/google_containers/k8s-dns-sidecar-amd64 "/sidecar --v=2 --lo…" 19 minutes ago Up 19 minutes k8s_sidecar_kube-dns-545bc4bfd4-xb5wz_kube-system_72374bf9-e06a-11e7-acaa-025000000001_0
666484ef5750 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 "/dnsmasq-nanny -v=2…" 20 minutes ago Up 20 minutes k8s_dnsmasq_kube-dns-545bc4bfd4-xb5wz_kube-system_72374bf9-e06a-11e7-acaa-025000000001_0
58d1dfc12392 gcr.io/google_containers/k8s-dns-kube-dns-amd64 "/kube-dns --domain=…" 20 minutes ago Up 20 minutes k8s_kubedns_kube-dns-545bc4bfd4-xb5wz_kube-system_72374bf9-e06a-11e7-acaa-025000000001_0
5f9ce35cf4b1 gcr.io/google_containers/kube-proxy-amd64 "/usr/local/bin/kube…" 21 minutes ago Up 21 minutes k8s_kube-proxy_kube-proxy-nthwt_kube-system_723b5384-e06a-11e7-acaa-025000000001_0
a37905c62b26 gcr.io/google_containers/pause-amd64:3.0 "/pause" 22 minutes ago Up 22 minutes k8s_POD_kube-dns-545bc4bfd4-xb5wz_kube-system_72374bf9-e06a-11e7-acaa-025000000001_0
7f31d9a0ba62 gcr.io/google_containers/pause-amd64:3.0 "/pause" 22 minutes ago Up 22 minutes k8s_POD_kube-proxy-nthwt_kube-system_723b5384-e06a-11e7-acaa-025000000001_0
855d8c2dc203 gcr.io/google_containers/kube-apiserver-amd64 "kube-apiserver --ad…" 22 minutes ago Up 22 minutes k8s_kube-apiserver_kube-apiserver-docker-for-desktop_kube-system_1a45b461b3c1e29ca080eac5d92e756d_2
da02e87d5fd2 gcr.io/google_containers/kube-controller-manager-amd64 "kube-controller-man…" 22 minutes ago Up 22 minutes k8s_kube-controller-manager_kube-controller-manager-docker-for-desktop_kube-system_d8fc73a6b14f7782d78cb9c7395f8965_1
a344bcdd48b8 gcr.io/google_containers/etcd-amd64 "etcd --listen-clien…" 22 minutes ago Up 22 minutes k8s_etcd_etcd-docker-for-desktop_kube-system_8cf2571a4c3f64cf3429d6f601861eec_0
a225b6224e62 gcr.io/google_containers/kube-scheduler-amd64 "kube-scheduler --ad…" 25 minutes ago Up 25 minutes k8s_kube-scheduler_kube-scheduler-docker-for-desktop_kube-system_972d74c9fc2f4ebd8ab673058e386a65_0
c52cadc8f021 gcr.io/google_containers/pause-amd64:3.0 "/pause" 26 minutes ago Up 26 minutes k8s_POD_kube-scheduler-docker-for-desktop_kube-system_972d74c9fc2f4ebd8ab673058e386a65_0
b54a9d28bf06 gcr.io/google_containers/pause-amd64:3.0 "/pause" 26 minutes ago Up 26 minutes k8s_POD_kube-controller-manager-docker-for-desktop_kube-system_d8fc73a6b14f7782d78cb9c7395f8965_0
d844694a8a9c gcr.io/google_containers/pause-amd64:3.0 "/pause" 26 minutes ago Up 26 minutes k8s_POD_kube-apiserver-docker-for-desktop_kube-system_1a45b461b3c1e29ca080eac5d92e756d_0
bf6234d6749e gcr.io/google_containers/pause-amd64:3.0 "/pause" 26 minutes ago Up 26 minutes k8s_POD_etcd-docker-for-desktop_kube-system_8cf2571a4c3f64cf3429d6f601861eec_0
Run the below commands:
Ajeets-MacBook-Air:~ ajeetraina$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
docker-for-desktop docker-for-desktop-cluster docker-for-desktop
* kubernetes-admin@kubernetes kubernetes kubernetes-admin
Change the context:
Ajeets-MacBook-Air:~ ajeetraina$ kubectl config use-context docker-for-desktop
Switched to context "docker-for-desktop".
Get Kubectl up and running:
Ajeets-MacBook-Air:~ ajeetraina$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-for-desktop Ready master 25m v1.8.2
Ajeets-MacBook-Air:~ ajeetraina$
Ajeets-MacBook-Air:~ ajeetraina$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}" | grep gcr
6278a1092d08 gcr.io/google_containers/kube-apiserver-amd64 v1.8.2
5eabb0eae58b gcr.io/google_containers/kube-controller-manager-amd64 v1.8.2
b48970f8473e gcr.io/google_containers/kube-scheduler-amd64 v1.8.2
88e2c85d3d02 gcr.io/google_containers/kube-proxy-amd64 v1.8.2
fed89e8b4248 gcr.io/google_containers/k8s-dns-sidecar-amd64 1.14.5
512cd7425a73 gcr.io/google_containers/k8s-dns-kube-dns-amd64 1.14.5
459944ce8cc4 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 1.14.5
243830dae7dd gcr.io/google_containers/etcd-amd64 3.0.17
99e59f495ffa gcr.io/google_containers/pause-amd64 3.0
Ajeets-MacBook-Air:~ ajeetraina$
Ajeets-MacBook-Air:~ ajeetraina$ kubectl cluster-info
Kubernetes master is running at https://localhost:6443
KubeDNS is running at https://localhost:6443/api/v1/namespaces/kube-system/services/kube-dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
As with most Kubernetes scripts, the kubectl command’s configuration is driven by environmental variables. When we executed the cluster installation script above, that script created a .kube configuration directory in my users home directory. Within that directory, it also created a file named config. This file is used to store information about the Kubernetes cluster that was created.
By setting the KUBECONFIG environmental variable to ~/.kube/config, we are defining that the kubectl command should reference this configuration file. Let’s take a quick look at that file to get a better understanding of what is being set.
The .kube/config file sets two main pieces of information:
- Location of the cluster
- Authentication data for communicating with that cluster
With the .kube/config file defined, let’s attempt to execute a kubectl command against our Kubernetes cluster to verify everything is working.
Ajeets-MacBook-Air:~ ajeetraina$ cat ~/.kube/config
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://localhost:6443
name: docker-for-desktop-cluster
- cluster:
certificate-authority-data: <>
server: https://localhost:6443
name: kubernetes
contexts:
- context:
cluster: docker-for-desktop-cluster
user: docker-for-desktop
name: docker-for-desktop
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: docker-for-desktop
kind: Config
preferences: {}
users:
- name: docker-for-desktop
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNTRENDQVRDZ0F3SUJBZ0lJRlFBRGczNWRsU3N3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4TnpFeU1UUXdNVEF5TVRoYUZ3MHhPREV5TVRRd01UQXlNVGhhTURNeApGREFTQmdOVkJBb1RDMFJ2WTJ0bGNpQkpibU11TVJzd0dRWURWUVFERXhKa2IyTnJaWEl0Wm05eUxXUmxjMnQwCmIzQXdnWjh3RFFZSktvWklodmNOQVFFQkJRQURnWTBBTUlHSkFvR0JBTWEzenNhVGVUOUZFMU1SbW45SXB4dHIKMmN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wzOS84T1JPNndNckFQUFprek8yeHViNTZUSEhiaAp1ZmNJL0ZDRnNVYVhGeWF6OHZXbG5TZ3B3VkRDNXdlM0hPYzRwQkVRZjN2ZERuR1NXbmZVYUNyNkcyc3NUUGt6Ck5neGUwUzYxOFYxM3F0Vkp3cFZVWWw0a01LMlpZZ0VPdmMvck12ZjhVanFkcXoxU056UT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
client-key-data: <>
kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-for-desktop Ready master 1h v1.8.2
The output of the ./kubectl get nodes command shows us that we were able to connect to our Kubernetes cluster and display the status of our master node. With this, we can move on as our installation is complete.
A Kubernetes Node is a physical or virtual (in our case, virtual) machine used to host application containers. In a traditional container-based environment, you would typically define that specific containers run on specified physical or virtual hosts. In a Kubernetes cluster, however, you simply define what application containers you wish to run. The Kubernetes master determines which node the application container will run on.
# Deploying Our Application
With our Kubernetes cluster ready, we can now start deploying application containers. The application container we will be deploying today will be an instance of Ghost. Ghost is a popular JavaScript-based blogging platform, and with its official Docker image, it’s pretty simple to deploy.
Since we’ll be using a prebuilt Docker container, we won’t need to first build a Docker image. However, it is important to call out that in order to use custom-built containers on a Kubernetes cluster. You must first build the container and push it to a Docker repository such as Docker Hub.
Ajeets-MacBook-Air:~ ajeetraina$ kubectl run ghost --image=ghost --port=2368
deployment "ghost" created
In the command above, we created a deployment named ghost, using the image ghost and specified that the ghost container requires the port 2368. Before going too far, let’s first verify that the container is running. We can verify this by executing the kubectl command with the get pods options.
Ajeets-MacBook-Air:~ ajeetraina$ kubectl get pods
NAME READY STATUS RESTARTS AGE
ghost-597fc5b679-c29dt 0/1 ContainerCreating 0 59s
The get pods option will tell the kubectl command to list all of the Kubernetes Pods currently deployed to the cluster.
Creating a service for Ghost
While containers within Pods can connect to systems external to the cluster, external systems and even other Pods cannot communicate with them. This is because, by default, the port defined for the Ghost service is not exposed beyond this cluster. This is where Services come into play.
In order to make our Ghost application accessible outside the cluster, the deployment we just created needs to be exposed as a Kubernetes Service. To set our Ghost deployment as a service, we will use the kubectl command once again, this time using the expose option.
Ajeets-MacBook-Air:~ ajeetraina$ kubectl expose deployment ghost --type="NodePort"
service "ghost" exposed
In the above command, we used the flag --type with the argument of NodePort. This flag defines the service type to expose for this service, in this case a NodePort service type. The NodePort service type will set all nodes to listen on the specified port. We can see our change take effect if we use the kubectl command again, but this time with the get services option.
Ajeets-MacBook-Air:~ ajeetraina$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ghost NodePort 10.107.149.248 <none> 2368:31151/TCP 51s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
Service types
At the moment, Kubernetes supports three service types:
ClusterIP
NodePort
LoadBalancer
If we wanted to only expose this service to other Pods within this cluster, we can use the ClusterIP service type, which is the default. This opens the port on each node for Pod to Pod communication.
The LoadBalancer service type is designed to provision an external IP to act as a Load Balancer for the service. Since our deployment is leveraging Vagrant on a local laptop, this option does not work in our environment. It does work with Kubernetes clusters deployed in cloud environments like GCE or AWS.
Testing our Ghost instance
Since we did not specify a port to use when defining our NodePort service, Kubernetes randomly assigned a port. To see what port it assigned, we can use the kubectl command, with the describe service option.
Ajeets-MacBook-Air:~ ajeetraina$ kubectl describe service ghost
Name: ghost
Namespace: default
Labels: run=ghost
Annotations: <none>
Selector: run=ghost
Type: NodePort
IP: 10.107.149.248
Port: <unset> 2368/TCP
TargetPort: 2368/TCP
NodePort: <unset> 31151/TCP
Endpoints: <none>
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Ajeets-MacBook-Air:~ ajeetraina$ curl -vk http://10.107.149.248:31151
* Rebuilt URL to: http://10.107.149.248:31151/
* Trying 10.107.149.248...
* TCP_NODELAY set
Once this command gives successful 200 OK response...From the output of the curl command, we can see that the connection was successful with a 200 OK response. What is interesting about this is that the request was to a node that wasn’t running the Ghost container. We can see this if we use the kubectl to describe the Pod.
Ajeets-MacBook-Air:~ ajeetraina$ kubectl describe pod ghost-597fc5b679-c29dt
Name: ghost-597fc5b679-c29dt
Namespace: default
Node: docker-for-desktop/192.168.65.2
Start Time: Thu, 14 Dec 2017 08:10:43 +0530
Labels: pod-template-hash=1539716235
run=ghost
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"ghost-597fc5b679","uid":"2e269fe4-e078-11e7-acaa-025000000001","...
Status: Pending
IP:
Created By: ReplicaSet/ghost-597fc5b679
Controlled By: ReplicaSet/ghost-597fc5b679
Containers:
ghost:
Container ID:
Image: ghost
Image ID:
Port: 2368/TCP
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-fwflq (ro)
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes:
default-token-fwflq:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-fwflq
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.alpha.kubernetes.io/notReady:NoExecute for 300s
node.alpha.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 8m default-scheduler Successfully assigned ghost-597fc5b679-c29dt to docker-for-desktop
Normal SuccessfulMountVolume 8m kubelet, docker-for-desktop MountVolume.SetUp succeeded for volume "default-token-fwflq"
Normal Pulling 8m kubelet, docker-for-desktop pulling image "ghost"
Ajeets-MacBook-Air:~ ajeetraina$
In the description above, we can see that the Ghost Pod is running on kubernetes-node-2. However, the HTTP request we just made was to kubernetes-node-1. This is made possible by a Kubernetes service called kube-proxy. With kube-proxy, whenever traffic arrives on a service’s port, the Kubernetes node will check if the service is running local to that node. If not, it will redirect the traffic to a node that is running that service.
In the case above, this means that even though the HTTP request was made to kubernetes-node-1, the kube-proxy service redirected that traffic to kubernetes-node-2 where the container is running.
This feature allows users to run services without having to worry about where the service is and whether or not it has moved from node to node. A very useful feature that reduces quite a bit of maintenance and headache.
Ajeets-MacBook-Air:~ ajeetraina$ vi local-volumes.yaml
Copy the content from https://raw.githubusercontent.com/kubernetes/website/master/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/local-volumes.yaml
Ajeets-MacBook-Air:~ ajeetraina$ kubectl create -f local-volumes.yaml
persistentvolume "local-pv-1" created
persistentvolume "local-pv-2" created
kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
local-pv-1 20Gi RWO Retain Available 59s
local-pv-2 20Gi RWO Retain Available 59s
Ajeets-MacBook-Air:~ ajeetraina$ kubectl create secret generic mysql-pass --from-literal=password=collab123
secret "mysql-pass" created
Ajeets-MacBook-Air:~ ajeetraina$ kubectl get secrets
NAME TYPE DATA AGE
default-token-fwflq kubernetes.io/service-account-token 3 1h
mysql-pass Opaque 1 15s
Ajeets-MacBook-Air:~ ajeetraina$
Copy mysql-deployment.yaml from https://raw.githubusercontent.com/kubernetes/website/master/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/local-volumes.yaml
Ajeets-MacBook-Air:~ ajeetraina$ kubectl create -f mysql-deployment.yaml
service "wordpress-mysql" created
persistentvolumeclaim "mysql-pv-claim" created
Ajeets-MacBook-Air:~ ajeetraina$ kubectl get pods
NAME READY STATUS RESTARTS AGE
ghost-597fc5b679-c29dt 0/1 ImagePullBackOff 0 21m
wordpress-mysql-7b4ffb6fb4-gfk8n 0/1 ContainerCreating 0 34s
Ajeets-MacBook-Air:~ ajeetraina$ kubectl create -f wordpress-deployment.yaml
service "wordpress" created
persistentvolumeclaim "wp-pv-claim" created
deployment "wordpress" created
Ajeets-MacBook-Air:~ ajeetraina$ kubectl get services wordpress
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
wordpress LoadBalancer 10.111.94.192 <pending> 80:31397/TCP 22s
deployment "wordpress-mysql" created
Ajeets-MacBook-Air:~ ajeetraina$ kubectl get pods
NAME READY STATUS RESTARTS AGE
ghost-597fc5b679-c29dt 1/1 Running 0 53m
wordpress-db8f78568-jkl8v 1/1 Running 0 31m
wordpress-mysql-7b4ffb6fb4-gfk8n 1/1 Running 0 32m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.