Estimated reading time: 3 minutes
I am using docker for mac 18.05.0-ce-mac66 (24545) (edge) with Kubernetes support and i am struggling with creating a kubernetes deployment referencing locally built image. You heard about it at DockerCon Europe and now it is here: we are proud to announce that Docker for Mac with beta Kubernetes support is now publicly available as part of the Edge release channel. We hope you are as excited as we are! With this release you can now run a single node Kubernetes cluster right on your Mac and use both kubectl commands and docker commands to control your containers.
Docker Desktop includes a standalone Kubernetes server and client,as well as Docker CLI integration. The Kubernetes server runs locally withinyour Docker instance, is not configurable, and is a single-node cluster.
The Kubernetes server runs within a Docker container on your local system, andis only for local testing. When Kubernetes support is enabled, you can deployyour workloads, in parallel, on Kubernetes, Swarm, and as standalone containers.Enabling or disabling the Kubernetes server does not affect your otherworkloads.
See Docker Desktop for Mac > Getting started toenable Kubernetes and begin testing the deployment of your workloads onKubernetes.
Use Docker commands
You can deploy a stack on Kubernetes with
docker stack deploy
, thedocker-compose.yml
file, and the name of the stack.You can see the service deployed with the
kubectl get services
command.Specify a namespace
By default, the
default
namespace is used. You can specify a namespace withthe --namespace
flag.Run
kubectl get services -n my-app
to see only the services deployed in themy-app
namespace.Override the default orchestrator
While testing Kubernetes, you may want to deploy some workloads in swarm mode.Use the
DOCKER_STACK_ORCHESTRATOR
variable to override the default orchestrator fora given terminal session or a single Docker command. This variable can be unset(the default, in which case Kubernetes is the orchestrator) or set to swarm
orkubernetes
. The following command overrides the orchestrator for a singledeployment, by setting the variableat the start of the command itself.Alternatively, the
--orchestrator
flag may be set to swarm
or kubernetes
when deploying to override the default orchestrator for that deployment.Note: Deploying the same app in Kubernetes and swarm mode may lead toconflicts with ports and service names.
Use the kubectl command
The mac Kubernetes integration provides the Kubernetes CLI commandat
/usr/local/bin/kubectl
. This location may not be in your shell’s PATH
variable, so you may need to type the full path of the command or add it tothe PATH
. For more information about kubectl
, see theofficial kubectl
documentation.You can test the command by listing the available nodes:Example app
Docker has created the following demo app that you can deploy to swarm mode orto Kubernetes using the
docker stack deploy
command.If you already have a Kubernetes YAML file, you can deploy it using the
mac, edge, kubernetes, kubectl, orchestrationEstimated Reading Time: 3minuteskubectl
command.Docker for Mac 18.01.0 CE is available for the general public. It holds experimental Kubernetes release running on Linux Kernel 4.9.75, Docker Compose 1.180 and Docker Machine 0.13.0. It is available only under Edge Release. Please note that this feature is still NOT available under Stable Release branch. This release brought a major fixes around insecure registry, VPNKit port, DNS timeout issues and many more which you can refer under Release Notes section.
[Updated – 29/01/2018 – Docker Inc. introduced Kubernetes context selector UI in the recent Docker for Mac 18.02 RC1 release. If you have Minikube already running on the same system, you can switch the context in between Minikube & docker for Mac flawlessly. Refer this for more information]
In my previous blog, I talked about how to build Kubernetes Cluster in 3 minutes using Kubectl tool which comes by default with this release. But what if you are a die-hard fan of Docker Swarm CLI like me, here is the good news – You can now use Swarm CLI to bring up Kubernetes Cluster. Under this post, I will show you how Swarm CLI can be used to bring up Kubernetes cluster in just 2 minutes.
Pre-requisite:
- Docker for Mac 18.01.0 CE Edge Release
- Enable Kubernetes under Preference > Kubernetes Tab
- Select Checkbox under Show System Container
A Quick 2-minutes ASCIINEMA video:
Here is 2-minutes video which shows how to get started from Zero to NGINX web server setup. It initiate with 0 pods, 0 external service and 0 deployments in Kubernetes terminology. Under this video, we will use the familiar
docker stack
CLI to bring up K8s cluster and then cleaning up in no seconds.Liked the video? You can refer this link for detailed instructions and further examples.
As I dig deeper into Kubernetes architecture, below links might be useful for anyone who want to learn Kubernetes concepts in detail.
Did you find this blog helpful? Feel free to share your experience. Get in touch @ajeetsraina.
If you are looking out for contribution/discussion, join me at Docker Community Slack Channel.