Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APISnoop template #15

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 231 additions & 0 deletions apisnoop/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
#+title: Kubevirt-talos

* Initialise providers
#+begin_src tmate
clusterctl init -b talos -c talos
#+end_src

* Install CDI support for KubeVirt
#+begin_src shell
export TAG=$(curl -s -w %{redirect_url} https://github.com/kubevirt/containerized-data-importer/releases/latest)
export VERSION=$(echo ${TAG##*/})
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-operator.yaml
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-cr.yaml
#+end_src

#+RESULTS:
#+begin_example
namespace/cdi created
customresourcedefinition.apiextensions.k8s.io/cdis.cdi.kubevirt.io created
clusterrole.rbac.authorization.k8s.io/cdi-operator-cluster created
clusterrolebinding.rbac.authorization.k8s.io/cdi-operator created
serviceaccount/cdi-operator created
role.rbac.authorization.k8s.io/cdi-operator created
rolebinding.rbac.authorization.k8s.io/cdi-operator created
deployment.apps/cdi-operator created
configmap/cdi-operator-leader-election-helper created
cdi.cdi.kubevirt.io/cdi created
#+end_example

* Coder Iteration Loop
** Start Coder
#+begin_src tmate :window coder :dir "../../.."

cd ~/sharingio/coder
rm -rf ~/.config/coderv2/ # delete database
coder server --address=0.0.0.0:7080 --access-url=https://coder.$SHARINGIO_PAIR_BASE_DNS_NAME \
2>&1 | tee coder-server.log
#+end_src
#+begin_src shell
coder login `cat ~/.config/coderv2/url` -u ii -p ii -e [email protected]
#+end_src

#+RESULTS:
#+begin_example
> Your Coder deployment hasn't been set up!

Welcome to Coder, ii! You're authenticated.

Get started by creating a template: coder templates init
#+end_example
** coder url
#+begin_src shell :dir "../../.."
grep "coder login https://" coder-server.log | cut -d\ -f 4
#+end_src

#+RESULTS:
#+begin_example
https://coder.bobymcbobs.pair.sharing.io
#+end_example


* kubevirt workspace
** create template and cluster

#+begin_src tmate :dir "../../.." :window kubevirt
cd ~/sharingio/coder
export CRI_PATH=/var/run/containerd/containerd.sock
export IMAGE_REPO=k8s.gcr.io
export NODE_VM_IMAGE_TEMPLATE=quay.io/capk/ubuntu-2004-container-disk:v1.22.0
coder template create kubevirt-talos \
-d examples/templates/kubevirt-talos \
--yes
coder create kv1 --template kubevirt-talos
#+end_src

** update template and new cluster

#+begin_src tmate :dir "../../.." :window kubevirt
export WORKSPACE=kv1
coder template push kubevirt-talos -d examples/templates/kubevirt-talos --yes
coder create $WORKSPACE --template kubevirt-talos --parameter-file examples/templates/kubevirt/kubevirt.param.yaml --yes
#+end_src

** grab new cluster kubeconfig

#+begin_src tmate :dir "../../.." :window kubectl
export WORKSPACE=kv1
unset KUBECONFIG
TMPFILE=$(mktemp -t kubeconfig-XXXXX)
kubectl get secrets -n $WORKSPACE ${WORKSPACE}-kubeconfig -o jsonpath={.data.value} | base64 -d > $TMPFILE
export KUBECONFIG=$TMPFILE
kubectl get ns
#+end_src

** inner cluster
#+begin_src shell
export WORKSPACE=kv1
unset KUBECONFIG
TMPFILE=$(mktemp -t kubeconfig-XXXXX)
kubectl get secrets -n $WORKSPACE ${WORKSPACE}-kubeconfig -o jsonpath={.data.value} | base64 -d > $TMPFILE
export KUBECONFIG=$TMPFILE
kubectl get all -A
#+end_src

#+RESULTS:
#+begin_example
NAMESPACE NAME READY STATUS RESTARTS AGE
default pod/code-server-0 0/1 Pending 0 81s
kube-system pod/coredns-749558f7dd-mwwff 0/1 Pending 0 81s
kube-system pod/coredns-749558f7dd-ppw92 0/1 Pending 0 81s
kube-system pod/etcd-kv1-97525 1/1 Running 0 90s
kube-system pod/kube-apiserver-kv1-97525 1/1 Running 0 90s
kube-system pod/kube-controller-manager-kv1-97525 1/1 Running 0 90s
kube-system pod/kube-proxy-48s9l 1/1 Running 0 81s
kube-system pod/kube-scheduler-kv1-97525 1/1 Running 0 90s

NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.95.0.1 <none> 443/TCP 97s
kube-system service/kube-dns ClusterIP 10.95.0.10 <none> 53/UDP,53/TCP,9153/TCP 96s

NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-system daemonset.apps/kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 96s

NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/coredns 0/2 2 0 96s

NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/coredns-749558f7dd 2 2 0 82s

NAMESPACE NAME READY AGE
default statefulset.apps/code-server 0/1 88s
#+end_example

** cni not yet working
#+begin_src shell :prologue "(\n" :epilogue "\n) 2>&1\n:\n"
export WORKSPACE=kv1
unset KUBECONFIG
TMPFILE=$(mktemp -t kubeconfig-XXXXX)
kubectl get secrets -n $WORKSPACE ${WORKSPACE}-kubeconfig -o jsonpath={.data.value} | base64 -d > $TMPFILE
export KUBECONFIG=$TMPFILE
kubectl describe nodes | grep -B6 KubeletNotReady
#+end_src

#+RESULTS:
#+begin_example
Conditions:
Type Status LastHeartbeatTime LastTransitionTime Reason Message
---- ------ ----------------- ------------------ ------ -------
MemoryPressure False Sat, 08 Oct 2022 23:39:08 -0600 Sat, 08 Oct 2022 23:38:52 -0600 KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure False Sat, 08 Oct 2022 23:39:08 -0600 Sat, 08 Oct 2022 23:38:52 -0600 KubeletHasNoDiskPressure kubelet has no disk pressure
PIDPressure False Sat, 08 Oct 2022 23:39:08 -0600 Sat, 08 Oct 2022 23:38:52 -0600 KubeletHasSufficientPID kubelet has sufficient PID available
Ready False Sat, 08 Oct 2022 23:39:08 -0600 Sat, 08 Oct 2022 23:38:52 -0600 KubeletNotReady container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:Network plugin returns error: cni plugin not initialized
#+end_example

** list all relevant resources
#+begin_src shell
kubectl get $(kubectl api-resources | grep -E 'x-k8s|sidero' | awk '{print $1}' | xargs | tr ' ' ','),secrets,configmaps,pods,svc,pvc,vmis -o wide -n kv10
#+end_src

#+RESULTS:
#+begin_example
NAME AGE
clusterresourceset.addons.cluster.x-k8s.io/kv10 25s

NAME AGE
talosconfig.bootstrap.cluster.x-k8s.io/kv10-nz842 5s

NAME AGE
talosconfigtemplate.bootstrap.cluster.x-k8s.io/kv10 27s

NAME PHASE AGE VERSION
cluster.cluster.x-k8s.io/kv10 Provisioned 24s

NAME CLUSTER DESIRED REPLICAS READY UPDATED UNAVAILABLE PHASE AGE VERSION
machinedeployment.cluster.x-k8s.io/kv10 kv10 0 Running 23s v1.23.5

NAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION
machine.cluster.x-k8s.io/kv10-mknmr kv10 Provisioning 5s v1.25.2

NAME CLUSTER DESIRED REPLICAS READY AVAILABLE AGE VERSION
machineset.cluster.x-k8s.io/kv10-7c6b4779d9 kv10 0 22s v1.23.5

NAME READY INITIALIZED REPLICAS READY REPLICAS UNAVAILABLE REPLICAS
taloscontrolplane.controlplane.cluster.x-k8s.io/kv10 1 1

NAME AGE
kubevirtcluster.infrastructure.cluster.x-k8s.io/kv10 26s

NAME AGE
kubevirtmachine.infrastructure.cluster.x-k8s.io/kv10-cp-9klxl 5s

NAME AGE
kubevirtmachinetemplate.infrastructure.cluster.x-k8s.io/kv10 22s
kubevirtmachinetemplate.infrastructure.cluster.x-k8s.io/kv10-cp 22s

NAME TYPE DATA AGE
secret/default-token-5f5r8 kubernetes.io/service-account-token 3 30s
secret/kv10-ca Opaque 2 5s
secret/kv10-kubeconfig cluster.x-k8s.io/secret 1 4s
secret/kv10-mknmr-bootstrap-data Opaque 1 5s
secret/kv10-mknmr-bootstrap-data-userdata cluster.x-k8s.io/secret 1 5s
secret/kv10-ssh-keys cluster.x-k8s.io/secret 2 24s
secret/kv10-talos Opaque 1 5s
secret/kv10-talosconfig Opaque 1 5s
secret/letsencrypt-prod kubernetes.io/tls 2 30s

NAME DATA AGE
configmap/capi-init 1 24s
configmap/kube-root-ca.crt 1 30s

NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/importer-kv10-cp-9klxl-vmdisk-dv 0/1 Pending 0 5s <none> <none> <none> <none>

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/kv10-lb ClusterIP 10.97.239.4 <none> 6443/TCP 24s cluster.x-k8s.io/cluster-name=kv10,cluster.x-k8s.io/role=control-plane

NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE VOLUMEMODE
persistentvolumeclaim/kv10-cp-9klxl-vmdisk-dv Pending local-path 5s Filesystem
#+end_example

* Tear down

#+begin_src tmate :window kubevirt
coder delete kv9
#+end_src

* Prepare
#+begin_src shell
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm template -n ingress-nginx ingress-nginx ingress-nginx/ingress-nginx --version 4.4.0 --values ./values/ingress-nginx.yaml > ./ingress-nginx.yaml
#+end_src
Loading