# Shoot Operations

Before you begin, please refer to [Operation 101](../operation-101.md) to learn how to access the different kinds of clusters and understand the overall landscape.

## Debugging shoot cluster

* Access a shoot cluster

    ```sh
    export KUBECONFIG=./garden-api
    kubectl get secret -n garden-${PORJECT} 8fd6130c.kubeconfig -ojsonpath='{.data.kubeconfig}' | base64 --decode >| ${PROJECT}.yaml
    kubectl --kubeconfig ${PROJECT}.yaml get po -n tidb1
    ```

* Check shoot cluster control plane

    ```sh
    kubectl get po -n shoot--${PROJECT}--<shoot_suffix>
    ```

    Sometimes, the node resources are all allocated, so the shoot control plane pod may stuck in pending state. This can be verified by `kubectl describe node` and check if the allocated resources are > 90%. If so, use following commands to remove the resources requests and limits for kube-apiserver which requires larger resources than other pods.

    ```sh
    kubectl describe node | grep apiserver
    kubectl edit deploy -n <shoot_control_plane_namespace> kube-apiserver
    ```

* SSH into a node in shoot cluster

    ```sh
    kubectl get no
    nodeName=<node-name-you-want-to-login>
    cat <<EOF > jumper.yaml
    apiVersion: v1
    kind: Pod
    metadata:
      name: jumper
    spec:
      nodeSelector:
        kubernetes.io/hostname: ${nodeName}
      tolerations:
      - operator: Exists
        effect: NoSchedule
      containers:
      - name: busybox
        image: busybox
        stdin: true
        securityContext:
          privileged: true
        volumeMounts:
        - name: host-root-volume
          mountPath: /host
          readOnly: true
      volumes:
      - name: host-root-volume
        hostPath:
          path: /
      hostNetwork: true
      hostPID: true
      restartPolicy: Never
    EOF
    kubectl apply -f jumper.yaml
    kubectl exec -it jumper sh
    chroot /host
    ```

    Remember to delete the pod when you are done with debug

## Hibernate all shoot clusters

```sh
export KUBECONFIG=./garden-api
kubectl get shoot -n garden-${PROJECT} --no-headers -o custom-columns=":metadata.name" | xargs -I {} kubectl patch shoot -n garden-${PROJECT} {} -p '{"spec": {"hibernation": {"enabled": true}}}'
```
