Flaky Deployments When Using Latest Docker For Mac

Flaky Deployments When Using Latest Docker For Mac

Jan 29, 2018 by During, Docker announced support and integration for Kubernetes, alongside Swarm. The first integration is in the Docker for Mac, where you can run now a 1 node Kubernetes cluster.

This allows you to deploy apps with Docker-compose files to that local Kubernetes cluster via the docker cli. In this blogpost, I’ll cover what you need to know about this integration and how to make the most out of it. Why we need local orchestration While a lot of computing workload moves to the cloud, the local environment is still relevant. This is the first place where software is built, executed and where (unit) tests run. Docker, helped us to get rid of the famous “it works on my machine” by automating the repetitive and error-prone tasks.

Flaky

But unless you’re into building “hello world” apps, you’ll have to manage the lifecycle of a bunch of containers that need to work together. Thus, you’ll need management for your running containers, commonly called nowadays orchestration. All major software orchestration platforms have their own “mini” distribution that can run on a developer machine.

If you work with Mesos you have (container based), for Kubernetes there is (virtual machine). RedHat offers both a virtual machine and a container based tool ( cli) for their K8s distribution (Openshift). Docker has, orchestration and since recently also supports (for now only in Docker for Mac). If you’re new to Kubernetes you’ll wanna familiarize with the basic concepts using this we build together with Google,. Installation Enabling Kubernetes in Docker for Mac, will install a containerized distribution of Kubernetes and it’s cli , which will allow you to interact with the cluster. On resource level, the new cluster will use whatever Docker for Mac has available for use. The release is in beta (at the time of writing the article) and available via the Docker Edge channel.

Once you’re logged in with your Docker account, you can enable Kubernetes via the dedicated menu from the UI: At this point, if you never connected to a Kubernetes cluster on your Mac, you’re good to go. Kubectl will point to the new (and only) configured cluster. If this is not the case, you’ll need to point kubectl to the right cluster.

Docker for Mac will not change your default Kubernetes context. You’ll need to manually switch the context to ‘docker-for-desktop’. KubeDNS is running at https: //localhost:6443/api/v1/namespaces/kube-system/services/kube-dns/proxy Note: You may have already another kubectl installed on your machine (E.g. Installed via gcloud utility if you used GKE before, or as a stand-alone program if you used minikube). Docker will install automatically a new kubectl binary in /usr/local/bin/. You’ll need to decide which one you’ll keep.

Flaky Deployments When Using Latest Docker For Mac

Deploying apps on the local Kubernetes cluster via Docker for Mac Ok, let’s try to install our first apps using a Docker-compose file. Yes, the previous sentence is correct. If you want to deploy apps to your new local Kubernetes cluster using the docker cli, docker-compose file is the only way.

If you already have some Kubernetes manifests you plan to deploy, you can do it using the known way, with kubectl. We’re using here the demo-app from the official docker-page about Kubernetes. Kubectl get all NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/db 1 1 1 1 39s deploy/web 1 1 1 1 39s deploy/words 1 1 1 1 39s NAME DESIRED CURRENT READY AGE rs/db-794c8bc8d9 1 1 1 39s rs/web-54cbf7d7fb 1 1 1 39s rs/words-575cd67dff 1 1 1 39s NAME READY STATUS RESTARTS AGE po/db-794c8bc8d9-mrw79 1/1 Running 0 39s po/web-54cbf7d7fb-mx4c7 1/1 Running 0 39s po/words-575cd67dff-ddgw2 1/1 Running 0 39s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/db ClusterIP None 55555/TCP 39s svc/web LoadBalancer 10.96.17.0/TCP 39s svc/words ClusterIP None 55555/TCP 39s. Svc / words ClusterIP None 55555 / TCP 39s Doing any change in the docker-compose file and re-deploying it (e.g.

Change the number of replicas, change the image version) will update the Kubernetes app accordingly. The concept of namespaces is supported as well via the -namespace parameter.

Deleting the application stacks can also be done via the docker cli. Implementation details Will Docker for Mac allow you to deploy with the docker cli the compose-files on other Kubernetes cluster? No, it won’t. Trying to deploy the same file on another cluster will return this error. '/apis/compose.docker.com/v1beta1' So at this point, if you want to deploy the same application stack on other clusters, you need to use something like Kompose to convert docker-compose files to Kubernetes manifests (it didn’t work for my example), or write the manifests by hand.

Using

That is it for configuring Jib! Now all that is required is simply to build the project and deploy the image to your local Docker repository.

In this case, I open the terminal and traverse inside of the SportsTeamQueryService-Jib project directory and issue the following Maven build: mvn clean install After the project has been built, invoke the Jib build by issuing the following: mvn compile jib:dockerBuild The Docker image should now be ready to start within the local Docker environment. To start the container, issue the following: docker run -d -p 8080:8080 sportsteamqueryservice The container should now be up and running. Visit the URL to see the list of players. In order to rebuild the Docker image, simply issue the command: mvn compile jib:dockerBuild Project Sources: https://github.com/juneau001/SportsTeamQueryService-Jib.

Comments are closed.