- Basic structure
- oc [name]
- There are some exceptions, like
oc help
oroc logs <pod>
oroc exec
- Most commands support
oc <command> --help
- Common resources (nouns)
- Pods
- Deployments
- Services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useful resources: https://github.com/ascode-com/wiki/tree/main/certified-kubernetes-administrator | |
alias ll='ls -l' | |
alias kcr='kubectl create' | |
alias ka='kubectl apply -f' | |
alias k=kubectl | |
alias kg='kubectl get' | |
alias ke='kubectl edit' | |
alias kd='kubectl describe' | |
alias kdd='kubectl delete' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: AKS Deployment | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
AZURE_CONTAINER_REGISTRY: "repo.azurecr.io" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Logs in to the Azure Container Registry | |
- uses: Azure/docker-login@v1 | |
with: | |
login-server: ${{ env.AZURE_CONTAINER_REGISTRY }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
# Build and push image to Azure Container Registry | |
- name: Build and push image to Azure Container Registry | |
run: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Logs in to the Azure Container Registry | |
- uses: Azure/docker-login@v1 | |
with: | |
login-server: ${{ env.AZURE_CONTAINER_REGISTRY }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
# Build and push image to Azure Container Registry | |
- name: Build and push image to Azure Container Registry | |
run: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: AKS Deployment | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
AZURE_CONTAINER_REGISTRY: "repo.azurecr.io" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Versoin one | |
oc get $(oc api-resources --namspaced=true | tail -n+2 | awk '{ print $1 }' | xargs | sed -e 's/\s/,/g') | |
# Version two (from https://access.redhat.com/solutions/4165791) | |
oc api-resources --verbs=list --namespaced -o name | xargs -n 1 oc get --show-kind --ignore-not-found -n $PROJECT_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -k "https://basic-ocp-demo-basic-ocp-demo-project.apps.cluster1.example.com/healthz" | |
# or build the curl URL programmatically! | |
curl -k "https://$(oc get route basic-ocp-demo -o jsonpath="{.spec.host}")/healthz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List images in k8s | |
ctr --namespace k8s.io image list | |
# Create etcd snapshot | |
ctr --namespace k8s.io \ | |
run \ | |
--mount type=bind,src={{ backup_temp_dir.path }}/,dst=/backup/,options=rbind:rw \ | |
--net-host \ | |
--env ETCDCTL_API=3 \ | |
--rm "{{ etcd_image_name.stdout | trim }}" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# crictl documentation: https://kubernetes.io/docs/tasks/debug-application-cluster/crictl/ | |
# Runtime endpoints: | |
sudo crictl --runtime-endpoint unix:///run/containerd/containerd.sock | |
sudo crictl --runtime-endpoint unix:///var/run/dockershim.sock | |
sudo crictl --runtime-endpoint unix:///run/crio/crio.sock | |
## Containers | |
# Get all containers |
NewerOlder