0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

kindでEphemeral Containerを有効にする

Last updated at Posted at 2022-01-18

はじめに

kind環境でEphemeral Containerがエラーで利用できなかったため対応をまとめました。

環境

  • kind: v0.11.1 go1.17.2 darwin/arm64
  • kubernetes(Server): v1.21.1

事象内容

以下コマンドを実行しようとしたところ以下のエラーが発生しました。

% kubectl debug sample-pod --image=amsy810/tools:v2.0 -it -- bash
Defaulting debug container name to debugger-wwzx2.
error: ephemeral containers are disabled for this cluster (error from server: "the server could not find the requested resource").

対応

エラーの内容は「ephemeral containersが有効になっていない」とのことなので kubernetes公式 を確認したところ、確かに今回のkubernetes v.1.21.1ではデフォルトは無効であることが判明。
image.png

kind公式のFeatureGatesの項 に記載がある通り、以下の様にkind.yamlを修正。

kind.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
featureGates:                #追加 
  EphemeralContainers: true  #追加 
nodes:
- role: control-plane
- role: worker
- role: worker

修正したkind.yamlでkindクラスタを起動し直した後、コマンドがエラーなく実行できることを確認しました。

% kubectl debug sample-pod --image=amsy810/tools:v2.0 -it -- bash
Defaulting debug container name to debugger-tttn5.
If you don't see a command prompt, try pressing enter.
root@sample-pod:/#

おわりに

他のFeature Gatesの機能をkindで有効にする場合も同じように記載すればよさそうです。


追記(2022/01/19)

クラスタのバージョンを上げれば良いとのコメントをいただき試してみました。
kind.confのノード定義にimageを追加して対応バージョン(1.23.0)を指定します。

kind.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# featureGates:                #コメントアウト or 行削除
#   EphemeralContainers: true  #コメントアウト or 行削除 
nodes:
- role: control-plane
  image: kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac
- role: worker
  image: kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac
- role: worker
  image: kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac

ノードが1.23.0で起動していることを確認。

% kubectl get nodes         
NAME                        STATUS   ROLES                  AGE   VERSION
kindcluster-control-plane   Ready    control-plane,master   12m   v1.23.0
kindcluster-worker          Ready    <none>                 12m   v1.23.0
kindcluster-worker2         Ready    <none>                 12m   v1.23.0

この環境でkubectl debugコマンドをエラーなく実行でき、Ephemeral Containerが利用できることを確認しました。

@superbrothers さま、情報ありがとうございました。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?