⚡️検証！Kubernetes v1.33 で Betaになった In-Place Pod Vertical Scaling を試す  

## はじめに 🔥  

Kubernetes 1.33 で **In-Place Pod Vertical Scaling (IPVS)** が Beta になりました。  

## 検証してみる ✨  

以下スクリプトを保存して実行するだけ。

内容は [Resize CPU and Memory Resources assigned to Containers | Kubernetes](https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/#example-1-resizing-cpu-without-restart) のExampleを参考にしています。

```bash
#!/usr/bin/env bash
K8S_VERSION="${K8S_VERSION:-v1.33.0}"
CLUSTER_NAME="resize-demo"
IMAGE="mirror.gcr.io/kindest/node:${K8S_VERSION}"

cleanup(){ kind delete cluster --name "${CLUSTER_NAME}" >/dev/null 2>&1 || true; }
trap cleanup EXIT

echo "🚀  Using image ${IMAGE}"
docker pull "${IMAGE}" >/dev/null 2>&1 || {
  echo "⚒️  Building node image locally…"
  [ -d kubernetes ] || git clone --depth 1 --branch "${K8S_VERSION}" https://github.com/kubernetes/kubernetes.git
  kind build node-image --type=bazel --image "${IMAGE}" --kube-root ./kubernetes
}

echo "⛵  Creating kind cluster…"
kind create cluster --name "${CLUSTER_NAME}" --image "${IMAGE}"

echo "✅  Cluster ready:"
kubectl version

sleep 10

cat > pod-resize.yaml <<'EOF'
apiVersion: v1
kind: Pod
metadata:
  name: resize-demo
spec:
  containers:
  - name: pause
    image: registry.k8s.io/pause:3.8
    resizePolicy:
    - resourceName: cpu
      restartPolicy: NotRequired
    - resourceName: memory
      restartPolicy: RestartContainer
    resources:
      requests: { cpu: 700m, memory: 200Mi }
      limits:   { cpu: 700m, memory: 200Mi }
EOF

kubectl apply -f pod-resize.yaml
kubectl wait --for=condition=Ready pod/resize-demo --timeout=60s

sleep 15

echo -e "\n🔧  CPU resize (700m → 800m, no restart expected)"
kubectl patch pod resize-demo --subresource resize --patch \
  '{"spec":{"containers":[{"name":"pause","resources":{"requests":{"cpu":"800m"},"limits":{"cpu":"800m"}}}]}}'

sleep 15
kubectl get pod resize-demo -o jsonpath='{.status.containerStatuses[0].restartCount}{"\n"}'

echo -e "\n🔧  Memory resize (200Mi → 300Mi, restart expected)"
kubectl patch pod resize-demo --subresource resize --patch \
  '{"spec":{"containers":[{"name":"pause","resources":{"requests":{"memory":"300Mi"},"limits":{"memory":"300Mi"}}}]}}'

sleep 15
kubectl get pod resize-demo -o jsonpath='{.status.containerStatuses[0].restartCount}{"\n"}'

echo -e "\n🎉  Demo complete — cluster will be removed when you exit."
sleep 15
```

## 実行結果 📸  

```console
$ ./resize-demo.sh
🚀  Using image mirror.gcr.io/kindest/node:v1.33.0
⛵  Creating kind cluster…
Creating cluster "resize-demo" ...
 ✓ Ensuring node image (mirror.gcr.io/kindest/node:v1.33.0) 🖼
 ✓ Preparing nodes 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
Set kubectl context to "kind-resize-demo"
You can now use your cluster with:

kubectl cluster-info --context kind-resize-demo

Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂
✅  Cluster ready:
Client Version: v1.33.0
Kustomize Version: v5.6.0
Server Version: v1.33.0
pod/resize-demo created
pod/resize-demo condition met

🔧  CPU resize (700m → 800m, no restart expected)
pod/resize-demo patched
0

🔧  Memory resize (200Mi → 300Mi, restart expected)
pod/resize-demo patched
1

🎉  Demo complete — cluster will be removed when you exit.
```

## **Troubleshooting: Infeasible resize request** 🛠  

`kubectl patch …` 後に **Pod が一向に変わらない** 場合は、`kubectl describe pod` で次の条件が付与されている可能性があります。

```yaml
status:
  conditions:
  - type: PodResizePending
    status: "True"
    reason: Infeasible
    message: "Node didn't have enough capacity: cpu, requested: 1000, capacity: 4000m"
```

詳しくは [Resize CPU and Memory Resources assigned to Containers | Kubernetes](https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/#troubleshooting-infeasible-resize-request) を参照してください.