Posts

Copy directories and files to and from Kubernetes Container [POD]

As we all know about  SCP   Linux command  to Copy the files and directories from a remote host to the local host and vice versa over  SSH . Similar to that we have ' KUBECTL CP ' to Copy the files and directories from a Kubernetes Container [POD] to the local host and vice versa. Syntax : kubectl cp <file-spec-src> <file-spec-dest> POD in a specific container kubectl cp <file-spec-src> <file-spec-dest> -c <specific-container> Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar Copy /tmp/foo from a remote pod to /tmp/bar locally kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar

“docker pull” certificate signed by unknown authority

first create a file -  /etc/docker/daemon.json than run the following to add certs openssl s_client -showcerts -connect <registry_address>:<registry_port> < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/docker/certs.d/<registry_address>/ca.crt works without restart OR import the cert to system like save the cert to the file , like the command above (the port is crucial, no need for the protocol) openssl s_client -showcerts -connect <registry_address>:<registry_port> < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ca.crt copy it to /usr/local/share/ca-certificates/ sudo cp ca.crt /usr/local/share/ca-certificates/ run update-ca-certificates sudo update-ca-certificates restart docker !

kaniko is a tool to build container images from a Dockerfile, inside a container or Kubernetes cluster

kaniko doesn't depend on a Docker daemon and executes each command within a Dockerfile completely in userspace. This enables building container images in environments that can't easily or securely run a Docker daemon, such as a standard Kubernetes cluster. https://github.com/GoogleContainerTools/kaniko#running-kaniko-in-docker

kURL - Open Source Kubernetes Installer online & Airgap

https://kurl.sh/ curl https://kurl.sh/latest | sudo bash

Standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder.

https://github.com/genuinetools/img img build -t forgegeek/img .

K8s installer offline

Nice project for k8s installation in offline & ansible Docs:- https://k8s-installer.github.io/ https://github.com/k8s-installer/k8s-installer/releases

How to install specific version of Kubernetes?

apt-get install -qy kubeadm=<version> curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \   echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \   sudo apt-get update -q && \   sudo apt-get install -qy kubelet=<version> kubectl=<version> kubeadm=<version> To get list of version kubeadm or kubectl. curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}' Example:- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \   echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \   sudo apt-get update -q && \   sudo apt-get install -qy kubelet=1.9.6-00 kubectl=1.9.6-00 kubeadm=1.9.6-00