kubernetes, kube tips

Kubernetes Tips - Part 2

This post is about writing Kubernetes configuration files with syntax checking and how to run a private Docker images on Kubernetes. Check other Kubernetes tips articles on my blog by using this tag kube-tips.

Writing Kubernetes Configuration Files

Kubernetes configuration files are pretty complex to write and mostly you will just copy/paste some existing resource and try to manage it to work for a new one. This approach is fine unless you need to add some new configuration options in the mix. I use Sublime Text text editor for almost everything, but I wasn't able to find a good syntax checker plugin for Kubernetes configuration files. I stumbled upon this great IDE, IntelliJ IDEA community edition which has a Kubernetes and OpenShift Resource Support plugin. IntelliJ IDEA is free and also the plugin.

The plugin provides assistance for editing YAML files containing Kubernetes resources. Optionally adds support for OpenShift resources in addition to native Kubernetes resources.

Features

  • Auto-completion of properties within resources
  • Popup documentation of properties
  • Inspections to detect and fix invalid, duplicated, and missing required properties
  • Supports Kubernetes 1.2 to 1.7 top-level resources

IntelliJ IDEA kubernetes

So, give it a try! If you are using something else let me know in the comments.

Using Private Docker Images

If you have Docker images stored on DockerHub or some other private registry provider and want to pull them to your Kuberntetes cluster, first you need to login to that service somehow. In Kubernetes you can do that by creating a docker-registry secret:

⚡ kubectl create secret docker-registry regsecret \
    --docker-username=USERNAME \
    --docker-password='PASSWORD' \
    [email protected]

Once you created a docker-registry secret regsecret, you need to add imagePullSecrets property to Pod configuration:

spec:
  imagePullSecrets:
    - name: regsecret

Your private images are available for a pull now.

If there’s something Kubernetes related you want to hear about, let me know in the comments, or tweet me at @alenkomljen.