-
Kubernetes Programming with Go En
-
Dev docs: https://github.com/kubernetes/community/tree/master/contributors/devel
This file contains hidden or 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
| apiVersion: deckhouse.io/v1alpha1 | |
| kind: NodeGroupConfiguration | |
| metadata: | |
| name: containerd-dvcr-config.sh | |
| spec: | |
| weight: 49 | |
| nodeGroups: ["*"] | |
| bundles: ["*"] | |
| content: | | |
| mkdir -p /etc/containerd/conf.d |
This file contains hidden or 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 | |
| export namespace=d8-virtualization | |
| export labels=("operator.kubevirt.io" "operator.cdi.kubevirt.io" "kubevirt.io" "cdi.kubevirt.io") | |
| export namespaces=(d8-cdi ${namespace}) | |
| # We need to delete kubevirt resource before operator! | |
| kubectl -n ${namespace} delete kubevirt kubevirt --force --grace-period=0 | |
| kubectl -n ${namespace} patch kubevirt kubevirt --type=json -p '[{ "op": "remove", "path": "/metadata/finalizers" }]' |
This file contains hidden or 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
| apiVersion: v1 | |
| kind: Namespace | |
| metadata: | |
| name: vms | |
| --- | |
| apiVersion: cdi.kubevirt.io/v1beta1 | |
| kind: DataVolume | |
| metadata: | |
| annotations: | |
| cdi.kubevirt.io/storage.bind.immediate.requested: "" |
This file contains hidden or 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
| ## Screenshots | |
| https://www.reddit.com/r/swaywm/comments/hczg3k/comment/fx9ur54/?utm_source=share&utm_medium=web2x&context=3 | |
| mode "print" { | |
| bindsym y exec grim -g "$(slurp)" - | wl-copy; mode "default" | |
| bindsym g exec grim -g "$(slurp)" "$(xdg-user-dir PICTURES)/Grimshot $(date +%c).png"; mode "default" | |
| bindsym s exec grim -g "$(slurp)" - | swappy -f -; mode "default" | |
| bindsym w exec swaymsg -t get_tree | jq -r '.. | (.nodes? // empty)[] | select(.focused) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)"' | grim -g - - | swappy -f -; mode "default" | |
| bindsym Escape mode "default" | |
| } |
This file contains hidden or 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
| # Workaround for GTK apps hanging during init | |
| # See https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start | |
| # See https://github.com/swaywm/sway/issues/5732 | |
| exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK | |
| exec dbus-update-activation-environment 2>/dev/null && \ | |
| dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK | |
| # End of workaround | |
| # Your preferred terminal emulator | |
| set $term terminator |
This file contains hidden or 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
| ```bash | |
| kubectl get pods -n test echo-lim-1000m-req-1000m -o json | jq '.spec.nodeName' -r virt/vms ⎈ 14:14:00 | |
| # virtlab-pt-1 | |
| kubectl get nodes $(kubectl get pods -n test echo-lim-1000m-req-1000m -o json | jq '.spec.nodeName' -r) -o json | jq '.status.addresses[] | select(.type=="InternalIP") | .address' -r | |
| # 172.18.18.21 | |
| kubectl get pods -n test echo-lim-1000m-req-1000m -o json | jq '.status.containerStatuses[0].containerID | split("://")[1]' -r virt/vms ⎈ SIGINT(2) ↵ 14:16:52 | |
| # b11ef417a0240e9e95cb4eb6cb0263a5f2f771ec8e10fc1d0f9abee4578f87ba |
This file contains hidden or 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
| kubectl get nodes -o json | jq -rc '.items[].status.addresses | reduce .[] as $node ({}; . + { "\($node.type)": "\($node.address)" })' | |
| # output example: | |
| # {"InternalIP":"192.168.199.238","ExternalIP":"172.16.66.221","Hostname":"dev0-istio-f6dfc5a3-78d85-bwzgf"} | |
| # {"InternalIP":"192.168.199.42","ExternalIP":"172.16.66.46","Hostname":"dev0-worker-f6dfc5a3-86445-7db72"} | |
| kubectl get nodes -o json 2>/dev/null | jq '[ .items[] | {int: .status.addresses[] | select(.type=="InternalIP") | .address , ext: .status.addresses[] | select(.type=="ExternalIP") | .address, name: .metadata.name } ]' | |
| # !!! It doesn't work if ExternalIP does not exist |
This file contains hidden or 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 | |
| orange=$(tput setaf 3) | |
| green=$(tput setaf 2) | |
| red=$(tput setaf 1) | |
| sgr0=$(tput sgr0) | |
| if [[ ${1} != "" ]]; then | |
| if ! kubectl get namespace ${1} >/dev/null 2>&1; then echo "Namespace ${1} doesn't exist"; exit; fi | |
| fi |
This file contains hidden or 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
| // SRC: https://www.zhaohuabing.com/post/2023-03-09-how-to-create-a-k8s-controller/ | |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "k8s.io/apimachinery/pkg/api/errors" | |
| "k8s.io/client-go/informers" | |
| "time" |