Kubectl
kubectl get secret postgres-credentials -o jsonpath="{.data}" | jq 'to_entries | .[] | "\(.key): \(.value | @base64d)"'
kubectl create secret generic azure-secrets --from-env-file <(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" azure-credentials.json)
kubectl rollout restart deployment/subgraph-pbf
Synopsis
Manage the rollout of one or many resources.
Valid resource types include:
- deployments
- daemonsets
- statefulsets
kubectl rollout SUBCOMMAND
Examples
# Rollback to the previous deployment
kubectl rollout undo deployment/abc
# Check the rollout status of a daemonset
kubectl rollout status daemonset/foo
# Restart a deployment
kubectl rollout restart deployment/abc
# Restart deployments with the 'app=nginx' label
kubectl rollout restart deployment --selector=app=nginx
kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1/namespaces/*/nginx_ingress_controller_per_second" | jq .
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl run <podname> --image=nginx --generator=run-pod/v1 --dry-run -o yaml
kubectl diff -R -f .
kube-ps1
curl https://raw.githubusercontent.com/jonmosco/kube-ps1/master/kube-ps1.sh -o ~/kube-ps1.sh
echo "source ~/kube-ps1.sh" >> ~/.bashrc
echo "PS1='[\u@\h \W $(kube_ps1)]\$ '" >> ~/.bashrc
Krew:
Make sure that git is installed.
Run this command to download and install krew:
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
Add the $HOME/.krew/bin directory to your PATH environment variable. To do this, update your .bashrc file and append the following line:
echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> ~/.bashrc
kubectx
kubectl krew install ctx
kubectl krew install ns
kubectl rollout restart <deployment>
kubectl get pods -o jsonpath='{range .items[*]}{range .spec.containers[*]}{.name}{"\t"}{.resources.requests.memory}{"\n"}{end}{end}'