kubectl-dev

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2021 License: Apache-2.0

README

kubectl-dev

kubectl-dev is a kubectl plugin to support development activities on k8s.

It offers you some capabilities to build images and debug them in k8s clusters directly. You don't need to install many runtime and many more versions of them in your laptop. No runtime changing and management. Also, no out-of-date garbage deps. All these are replaced by a k8s cluster.

Currently, the plugin can only work with containerd. All features work well in a minikube cluster.

How to debug failed apps efficiently?

If a app failed, it could crash, wait for deps and has no responding, fails on some libraries, say some .so files, or get wrong mounted ConfigMaps or Secrets. K8s provides nothing to figure them out. The only thing may help is logs your app printed.

The debug command provides a new way to start the workload. It creates an identical Pod in the same namespace, except the image of the target container. debug opens a bash session after the Pod started. The target image is mount to /image. Its original parameters are set in the environment variable IMAGE_ARGS. You can check the original image context or debug the binary in the opened session.

This command also supports Docker as container runtime. But, it needs a few more steps to install deps. See Install csi-driver-image on Docker.

Install

kubectl is required to manage necessary objects. We also assumed that you have a k8s cluster, or a minikube cluster.

The csi-driver-image is also needed by the debug command. You can install the predefined manifests via the --also-apply-csi-driver option while starting the debug command. Or, you can also apply custom manifests manually.

You can download the binary for either Linux or MacOS from the Release page. Then put it into your PATH directory.

Usage

# Debug the Deployment named workload and install the CSI driver.
 # For the containerd runtime,
 kubectl dev debug deploy workload --also-apply-csi-driver

 # For the containerd runtime in minikube clusters,
 kubectl dev debug deploy workload --also-apply-csi-driver --minikube

 # For the docker runtime,
 kubectl dev debug deploy workload --also-apply-csi-driver --docker

# Install build toolchains.
kubectl dev build install

# Install build toolchains in minikube cluster.
kubectl dev build install --minikube

# Build image in cluster using docker parameters and options.
kubectl dev build -t docker.io/warmmetal/image:tag -f test.dockerfile .

Build

# For MacOS
kubectl dev build  -f hack/dev/Dockerfile --local _output/ --target mac-cli

# For Linux
kubectl dev build  -f hack/dev/Dockerfile --local _output/ --target linux-cli

Directories

Path Synopsis
cmd
dev command
f2cm command
pkg
cmd
dev

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL