Making Kubernetes How We Build Things
This talk is all live demos of tools developers can use in their inner-loop, at development time to be more productive with containers.
Docker Compose captures the build arguments and run arguments so we can focus on our coding.
As we explore Docker Compose, we use
network_mode: bridge to avoid creating a new overlay network for the compose file contents. This allows us to easily network between containers from multiple docker-compose.yaml files.
Minikube is an alternate Docker runtime that is more compatible with nested virtualization scenarios and keeps a more modern version of Kubernetes.
minikube start, run
minikube docker-env to get the environment variables you'll set to allow the Docker CLI to work easily with the container runtime inside Minikube.
I wish there was a
but there isn't. Instead we can use Skaffold.
docker watch ...
skaffold init to generate a yaml file, then tweak it to identify the image name to build and the kubernetes yaml file to run. You can optionally push to a remote container registry.
Visualize container contents
Dive allows you to view the files in each container layer.
docker history ... shows you the commands that were run at each layer, but it doesn't show you the container contents. We use Dive to notice that we copied in too many files, and we need to adjust the
Visualize running containers
In this section we look at 3 tools that allow us to see our cluster.
LazyDocker is a command-line tool to visualize a Docker cluster. It has really cool mouse behaviors ... that don't work in Windows, but it has great key bindings that allow you to navigate through images, volumes, containers, logs, and config.
Portainer is a great web-based tool to visualize the Docker-side of a cluster. Grab a docker-compose.yaml file, quickly spin it up, and you can visualize, remote into, and kill containers with ease on a local or remote cluster.
K8Dash (now called Skooner) is a great way to view the Kubernetes-side of a cluster. View deployments, pods, volumes, secrets, and other k8s resources. Grab the secret you created as you spun it up to login.
Debug inside containers
VS Code Remoting allows debugging processes inside containers.
Once you have the extension installed, you can click the green icon on the bottom-left to start a sample, generate the .devcontainer folder contents, or launch VS Code from inside a container. In this mode, VS code splits in half. The UI half is running locally and handles colors, fonts, and themes. The other half is running inside the container, and handles running the app, and intellisense for your language of choice. We fire up the app to see how VS Code Remoting automatically proxies the web port to our local machine.