{"_id":"q-en-website-00b44408a3ade2884986795b330c856ef2d37da834bf453e0a21c58540392863","text":" --- title: ReplicaSet id: replica-set date: 2018-04-12 full_link: /ja/docs/concepts/workloads/controllers/replicaset/ short_description: > ReplicaSetは、指定された数のPodレプリカが一度に動作するように保証します。 aka: tags: - fundamental - core-object - workload --- ReplicaSetは、任意の時点で動作しているレプリカPodの集合を保持します。(保持することを目指します。) {{< glossary_tooltip term_id=\"deployment\" >}}などのワークロードオブジェクトは、ReplicaSetの仕様に基づいて、 設定された数の{{< glossary_tooltip term_id=\"pod\" text=\"Pods\" >}}がクラスターで稼働することを保証するために、 ReplicaSetを使用します。 "} {"_id":"q-en-website-0131b3cf171ebce25201685759bb09324016e9d2074e036d39fbb0811320f0cc","text":" # *Stop. This guide has been superseded by [Minikube](../minikube/). The link below is present only for historical purposes* The document has been moved to [here](https://github.com/kubernetes/kubernetes/blob/master/docs/devel/local-cluster/docker.md) "} {"_id":"q-en-website-0207c751d7a056d4e4339bf5a96b968343a847f922179dac47139930d4d493e6","text":"Attempt to drain the node on which `zk-2` is scheduled. ```shell kubectl drain $(kubectl get pod zk-2 --template {{.spec.nodeName}}) --ignore-daemonsets --force --delete-local-data kubectl drain $(kubectl get pod zk-2 --template {{.spec.nodeName}}) --ignore-daemonsets --force --delete-emptydir-data ``` The output:"} {"_id":"q-en-website-025dc021e1633379fa2c6a581abe4c6445e2a7b8d6842553c1e3289d61259363","text":"Follow the [Konnectivity service task](/docs/tasks/extend-kubernetes/setup-konnectivity/) to set up the Konnectivity service in your cluster. ## {{% heading \"whatsnext\" %}} * Read about the [Kubernetes control plane components](/docs/concepts/overview/components/#control-plane-components) * Learn more about [Hubs and Spoke model](https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts.html#hubs-spokes-and-other-wheel-metaphors) * Learn how to [Secure a Cluster](/docs/tasks/administer-cluster/securing-a-cluster/) * Learn more about the [Kubernetes API](/docs/concepts/overview/kubernetes-api/) * [Set up Konnectivity service](/docs/tasks/extend-kubernetes/setup-konnectivity/) * [Use Port Forwarding to Access Applications in a Cluster](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/) * Learn how to [Fetch logs for Pods](/docs/tasks/debug/debug-application/debug-running-pod/#examine-pod-logs), [use kubectl port-forward](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/#forward-a-local-port-to-a-port-on-the-pod) No newline at end of file"} {"_id":"q-en-website-03e61fb03a710b2080a4e5cd0bd40bc485b86cad62b75564650174b508f3e3fa","text":"1. Validate the binary (optional) Download the kubectl-convert checksum file: Download the `kubectl-convert` checksum file: ```powershell curl -LO \"https://dl.k8s.io/{{< param \"fullversion\" >}}/bin/windows/amd64/kubectl-convert.exe.sha256\" ``` Validate the kubectl-convert binary against the checksum file: Validate the `kubectl-convert` binary against the checksum file: - Using Command Prompt to manually compare `CertUtil`'s output to the checksum file downloaded:"} {"_id":"q-en-website-050fa3b4a42eb4746c334f00db6417127cae641747fa7452450651007a4fad60","text":"{{% tab name=\"Linux\" %}} 1. 从官方Docker仓库安装 `containerd.io` 软件包。可以在 [安装 Docker 引擎](https://docs.docker.com/engine/install/#server)"} {"_id":"q-en-website-05c82aeb721fc079c480dc4a89ae94bb5b1777f4b5b39dc14ab4c3f0cfad16fb","text":"/docs/concepts/scheduling-eviction/eviction-policy/ /docs/concepts/scheduling-eviction/node-pressure-eviction/ 301 /docs/concepts/service-catalog/ /docs/concepts/extend-kubernetes/service-catalog/ 301 /docs/concepts/services-networking/networkpolicies/ /docs/concepts/services-networking/network-policies/ 301 /docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/ /docs/tasks/network/customize-hosts-file-for-pods/ 301 /docs/concepts/storage/etcd-store-api-object/ /docs/tasks/administer-cluster/configure-upgrade-etcd/ 301 /docs/concepts/storage/volumes/emptyDirapiVersion/ /docs/concepts/storage/volumes/#emptydir/ 301 /docs/concepts/tools/kubectl/object-management-overview/ /docs/concepts/overview/object-management-kubectl/overview/ 301"} {"_id":"q-en-website-08b05c7e2efa36361f7cb00fa78cadf4e0eed86a367de3ab735dae3fe5c086c8","text":"## kubeadm upgrade guidance The steps for performing a upgrade using kubeadm are outlined in [this document](/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/). The steps for performing an upgrade using kubeadm are outlined in [this document](/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/). For older versions of kubeadm, please refer to older documentation sets of the Kubernetes website. You can use `kubeadm upgrade diff` to see the changes that would be applied to static pod manifests."} {"_id":"q-en-website-08cac924b91dc61c251d898a33d63d05d0b56f71fa7cc9a7b573bf9a0ffd8112","text":" apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: /$1 spec: rules: - host: hello-world.info http: paths: - path: / pathType: Prefix backend: service: name: web port: number: 8080 No newline at end of file"} {"_id":"q-en-website-0a4567cfd1a3859111997989c5b45427dfbbb0f37a5ab453ac4f6f6e1122ff25","text":"/* DOCS */ .launch-cards { button { cursor: pointer; box-sizing: border-box; background: none; margin: 0; border: 0; } padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); row-gap: 1em; .launch-card { display: flex; padding: 0 30px 0 0; .card-content{ width: fit-content; display: flex; flex-direction: column; margin: 0; row-gap: 1em; h2 { font-size: 1.75em; padding: 0.5em 0; margin: 0; a { display: none; } } p { margin: 0; } ul { list-style: none; height: fit-content; line-height: 1.6; padding: 0; margin-block-end: auto; } br { display: none; } button { height: min-content; width: auto; padding: .5em 1em; cursor: pointer; box-sizing: border-box; } } } ul, li { list-style: none; padding-left: 0; } @media only screen and (max-width: 1000px) { grid-template-columns: 1fr; .launch-card { width: 100%; } } } // table of contents .td-toc { padding-top: 1.5rem !important;"} {"_id":"q-en-website-0b944463633971e8baea55b9c3e34dedd415eb4421527bd7a0ea067ee137614d","text":"For more information about the authentication process, refer to [Authentication](/docs/reference/access-authn-authz/authentication/#service-account-tokens). ### Authenticating service account credentials in your own code {authenticating-in-code} ### Authenticating service account credentials in your own code {#authenticating-in-code} If you have services of your own that need to validate Kubernetes service account credentials, you can use the following methods:"} {"_id":"q-en-website-0e4147819ad7a6101406dfe4e3ba7da5d35e7380b0833b1cfa61b64bfa824f9a","text":"if you have 3 registered clusters and you create a federated ReplicaSet with `spec.replicas = 9`, then each ReplicaSet in the 3 clusters will have `spec.replicas=3`. To modify the number of replicas in each cluster, you can specify [FederatedReplicaSetPreference](https://github.com/kubernetes/federation/blob/{{page.githubbranch}}/apis/federation/types.go) as an annotation with key `federation.kubernetes.io/replica-set-preferences` on the federated ReplicaSet. To modify the number of replicas in each cluster, you can add an annotation with key `federation.kubernetes.io/replica-set-preferences` to the federated ReplicaSet. The value of the annoation is a serialized JSON that contains fields shown in the following example: ``` { \"rebalance\": true, \"clusters\": { \"foo\": { \"minReplicas\": 10, \"maxReplicas\": 50, \"weight\": 100 }, \"bar\": { \"minReplicas\": 10, \"maxReplicas\": 100, \"weight\": 200 } } } ``` The `rebalance` boolean field specifies whether replicas already scheduled and running may be moved in order to match current state to the specified preferences. The `clusters` object field contains a map where users can specify the constraints for replica placement across the clusters (`foo` and `bar` in the example). For each cluster, you can specify the minimum number of replicas that should be assigned to it (default is zero), the maximum number of replicas the cluster can accept (default is unbounded) and a number expressing the relative weight of preferences to place additional replicas to that cluster. ## Updating a Federated ReplicaSet"} {"_id":"q-en-website-0e7ebc11c1b876291b45fe8ffa6286e7eedb4c4af076efb11e2b772de2e10046","text":" --- title: Minikube上でNGINX Ingressコントローラーを使用してIngressをセットアップする content_type: task weight: 100 --- [Ingress](/ja/docs/concepts/services-networking/ingress/)とは、クラスター内のServiceに外部からのアクセスを許可するルールを定義するAPIオブジェクトです。[Ingressコントローラー](/ja/docs/concepts/services-networking/ingress-controllers/)はIngress内に設定されたルールを満たすように動作します。 このページでは、簡単なIngressをセットアップして、HTTPのURIに応じてwebまたはweb2というServiceにリクエストをルーティングする方法を説明します。 ## {{% heading \"prerequisites\" %}} {{< include \"task-tutorial-prereqs.md\" >}} {{< version-check >}} ## Minikubeクラスターを作成する 1. **Launch Terminal**をクリックします。 {{< kat-button >}} 1. (オプション) Minikubeをローカル環境にインストールした場合は、次のコマンドを実行します。 ```shell minikube start ``` ## Ingressコントローラーを有効化する 1. NGINX Ingressコントローラーを有効にするために、次のコマンドを実行します。 ```shell minikube addons enable ingress ``` 1. NGINX Ingressコントローラーが起動したことを確認します。 ```shell kubectl get pods -n kube-system ``` {{< note >}} このコマンドの実行には数分かかる場合があります。 {{< /note >}} 出力は次のようになります。 ```shell NAME READY STATUS RESTARTS AGE default-http-backend-59868b7dd6-xb8tq 1/1 Running 0 1m kube-addon-manager-minikube 1/1 Running 0 3m kube-dns-6dcb57bcc8-n4xd4 3/3 Running 0 2m kubernetes-dashboard-5498ccf677-b8p5h 1/1 Running 0 2m nginx-ingress-controller-5984b97644-rnkrg 1/1 Running 0 1m storage-provisioner 1/1 Running 0 2m ``` ## Hello Worldアプリをデプロイする 1. 次のコマンドを実行して、Deploymentを作成します。 ```shell kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0 ``` 出力は次のようになります。 ```shell deployment.apps/web created ``` 1. Deploymentを公開します。 ```shell kubectl expose deployment web --type=NodePort --port=8080 ``` 出力は次のようになります。 ```shell service/web exposed ``` 1. Serviceが作成され、NodePort上で利用できるようになったことを確認します。 ```shell kubectl get service web ``` 出力は次のようになります。 ```shell NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE web NodePort 10.104.133.249 8080:31637/TCP 12m ``` 1. NodePort経由でServiceを訪問します。 ```shell minikube service web --url ``` 出力は次のようになります。 ```shell http://172.17.0.15:31637 ``` {{< note >}} Katacoda環境の場合のみ: 上部のterminalパネルでプラスのアイコンをクリックして、**Select port to view on Host 1**(Host 1を表示するポートを選択)をクリックします。NodePort(上の例では`31637`)を入力して、**Display Port**(ポートを表示)をクリックしてください。 {{< /note >}} 出力は次のようになります。 ```shell Hello, world! Version: 1.0.0 Hostname: web-55b8c6998d-8k564 ``` これで、MinikubeのIPアドレスとNodePort経由で、サンプルアプリにアクセスできるようになりました。次のステップでは、Ingressリソースを使用してアプリにアクセスできるように設定します。 ## Ingressリソースを作成する 以下に示すファイルは、hello-world.info経由で送られたトラフィックをServiceに送信するIngressリソースです。 1. 以下の内容で`example-ingress.yaml`を作成します。 ```yaml apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: example-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: /$1 spec: rules: - host: hello-world.info http: paths: - path: / backend: serviceName: web servicePort: 8080 ``` 1. 次のコマンドを実行して、Ingressリソースを作成します。 ```shell kubectl apply -f example-ingress.yaml ``` 出力は次のようになります。 ```shell ingress.networking.k8s.io/example-ingress created ``` 1. 次のコマンドで、IPアドレスが設定されていることを確認します。 ```shell kubectl get ingress ``` {{< note >}} このコマンドの実行には数分かかる場合があります。 {{< /note >}} ```shell NAME HOSTS ADDRESS PORTS AGE example-ingress hello-world.info 172.17.0.15 80 38s ``` 1. 次の行を`/etc/hosts`ファイルの最後に書きます。 {{< note >}} Minikubeをローカル環境で実行している場合、`minikube ip`コマンドを使用すると外部のIPが取得できます。Ingressのリスト内に表示されるIPアドレスは、内部のIPになるはずです。 {{< /note >}} ``` 172.17.0.15 hello-world.info ``` この設定により、リクエストがhello-world.infoからMinikubeに送信されるようになります。 1. Ingressコントローラーがトラフィックを制御していることを確認します。 ```shell curl hello-world.info ``` 出力は次のようになります。 ```shell Hello, world! Version: 1.0.0 Hostname: web-55b8c6998d-8k564 ``` {{< note >}} Minikubeをローカル環境で実行している場合、ブラウザからhello-world.infoにアクセスできます。 {{< /note >}} ## 2番目のDeploymentを作成する 1. 次のコマンドを実行して、v2のDeploymentを作成します。 ```shell kubectl create deployment web2 --image=gcr.io/google-samples/hello-app:2.0 ``` 出力は次のようになります。 ```shell deployment.apps/web2 created ``` 1. Deploymentを公開します。 ```shell kubectl expose deployment web2 --port=8080 --type=NodePort ``` 出力は次のようになります。 ```shell service/web2 exposed ``` ## Ingressを編集する 1. 既存の`example-ingress.yaml`を編集して、以下の行を追加します。 ```yaml - path: /v2 backend: serviceName: web2 servicePort: 8080 ``` 1. 次のコマンドで変更を適用します。 ```shell kubectl apply -f example-ingress.yaml ``` 出力は次のようになります。 ```shell ingress.networking/example-ingress configured ``` ## Ingressを試す 1. Hello Worldアプリの1番目のバージョンにアクセスします。 ```shell curl hello-world.info ``` 出力は次のようになります。 ```shell Hello, world! Version: 1.0.0 Hostname: web-55b8c6998d-8k564 ``` 1. Hello Worldアプリの2番目のバージョンにアクセスします。 ```shell curl hello-world.info/v2 ``` 出力は次のようになります。 ```shell Hello, world! Version: 2.0.0 Hostname: web2-75cd47646f-t8cjk ``` {{< note >}} Minikubeをローカル環境で実行している場合、ブラウザからhello-world.infoおよびhello-world.info/v2にアクセスできます。 {{< /note >}} ## {{% heading \"whatsnext\" %}} * [Ingress](/ja/docs/concepts/services-networking/ingress/)についてさらに学ぶ。 * [Ingressコントローラー](/ja/docs/concepts/services-networking/ingress-controllers/)についてさらに学ぶ。 * [Service](/ja/docs/concepts/services-networking/service/)についてさらに学ぶ。 "} {"_id":"q-en-website-0f00ca41e6af3362e87594bd2906baca7db53b34ca3017606974c111277b1cba","text":"--> 仅当 `Guaranteed` Pod 中所有容器都被指定了请求和限制并且二者相等时,才保证 Pod 不被驱逐。 这些 Pod 永远不会因为另一个 Pod 的资源消耗而被驱逐。 如果系统守护进程(例如 `kubelet`、`docker` 和 `journald`) 如果系统守护进程(例如 `kubelet` 和 `journald`) 消耗的资源比通过 `system-reserved` 或 `kube-reserved` 分配保留的资源多, 并且该节点只有 `Guaranteed` 或 `Burstable` Pod 使用的资源少于其上剩余的请求, 那么 kubelet 必须选择驱逐这些 Pod 中的一个以保持节点稳定性并减少资源匮乏对其他 Pod 的影响。"} {"_id":"q-en-website-121da4feb787e365949cf511ed93916e5988f133779efcc8d10a5507b46bbe1e","text":"cgroupDriver: systemd ``` {{< note >}} Starting with v1.22 and later, when creating a cluster with kubeadm, if the user does not set the `cgroupDriver` field under `KubeletConfiguration`, kubeadm defaults it to `systemd`. {{< /note >}} If you configure `systemd` as the cgroup driver for the kubelet, you must also configure `systemd` as the cgroup driver for the container runtime. Refer to the documentation for your container runtime for instructions. For example:"} {"_id":"q-en-website-1317bde09d61c92e98f6ab4576e1409779037ed8a32213665b9db553e643bb28","text":" --- title: \"通过 gcloud 安装 kubectl\" description: \"用各个特定操作系统标签页中包含的 gcloud 指令片段安装 kubectl。\" headless: true --- kubectl 可以作为 Google Cloud SDK 的一部分被安装。 1. 安装 [Google Cloud SDK](https://cloud.google.com/sdk/)。 1. 运行安装 `kubectl` 的命令: ```shell gcloud components install kubectl ``` 1. 验证一下,确保安装的是最新的版本: ```shell kubectl version --client ``` No newline at end of file"} {"_id":"q-en-website-133bbe6cbc61dda136292a6ad16083aab31fc278aa771a81c8f6e8c3ec88d6e3","text":"cat <./kustomization.yaml configMapGenerator: - name: game-config-5 labels: game-config: config-5 options: labels: game-config: config-5 files: - game-special-key=configure-pod-container/configmap/game.properties EOF"} {"_id":"q-en-website-136384196b08438466eb349f339d5333739b2a13835b82a6cf6ec305903a5144","text":"* `apiserver_flowcontrol_priority_level_request_count_watermarks` is a histogram vector of high or low water marks of the number of requests broken down by the labels `phase` (which takes on the values `waiting` and `executing`) and `priorityLevel`; the label values `waiting` and `executing`) and `priority_level`; the label `mark` takes on values `high` and `low`. The water marks are accumulated over windows bounded by the times when an observation was added to"} {"_id":"q-en-website-13723dce4f1ad8fae0515a3b701c8828a6b396b2c12310ffba065e0535630a76","text":" --- no_issue: true title: Instalação main_menu: true weight: 30 content_type: concept --- Essa seção lista as diferentes formas de instalar e executar o Kubernetes. Quando você realiza a instalação de um cluster Kubernetes, deve decidir o tipo de instalação baseado em critérios como facilidade de manutenção, segurança, controle, quantidade de recursos disponíveis e a experiência necessária para gerenciar e operar o cluster. Você pode criar um cluster Kubernetes em uma máquina local, na nuvem, em um datacenter on-premises ou ainda escolher uma oferta de um cluster Kubernetes gerenciado pelo seu provedor de computação em nuvem. Existem ainda diversos outros tipos de soluções customizadas, que você pode se deparar ao buscar formas de instalação e gerenciamento de seu cluster. ## Ambientes de aprendizado Se você está aprendendo ou pretende aprender mais sobre o Kubernetes, use ferramentas suportadas pela comunidade, ou ferramentas no ecossistema que te permitam criar um cluster Kubernetes em sua máquina virtual. Temos como exemplo aqui o [Minikube](/docs/tasks/tools/install-minikube/) e o [KinD](https://kind.sigs.k8s.io/docs/user/quick-start/) ## Ambientes de produção Ao analisar uma solução para um ambiente de produção, devem ser considerados quais aspectos de operação de um cluster Kubernetes você deseja gerenciar, ou então delegar ao seu provedor. Temos diversas opções para esse provisionamento, desde o uso de uma ferramenta de deployment de um cluster tal qual o [Kubeadm](/docs/setup/production-environment/tools/kubeadm/install-kubeadm/) ou o [Kubespray](/docs/setup/production-environment/tools/kubespray/) quando se trata de um cluster local, ou ainda o uso de um cluster gerenciado por seu provedor de nuvem. Para a escolha do melhor ambiente e da melhor forma para fazer essa instalação, você deve considerar: * Se você deseja se preocupar com a gestão de backup da sua estrutura do ambiente de gerenciamento * Se você deseja ter um cluster mais atualizado, com novas funcionalidades, ou se deseja seguir a versão suportada pelo fornecedor * Se você deseja ter um cluster com um alto nível de serviço, ou com auto provisionamento de alta disponibilidade * Quanto você deseja pagar por essa produção "} {"_id":"q-en-website-15a27e82fd3d2192fa3c8262c694ad4c7301d5086e7f783731d77c65bfa87b39","text":" --- title: 临时卷 content_type: concept weight: 50 --- 本文档描述 Kubernetes 中的 _临时卷(Ephemeral Volume)_。 建议先了解[卷](/zh/docs/concepts/storage/volumes/),特别是 PersistentVolumeClaim 和 PersistentVolume。 有些应用程序需要额外的存储,但并不关心数据在重启后仍然可用,既是否被持久地保存。 例如,缓存服务经常受限于内存大小,将不常用的数据转移到比内存慢、但对总体性能的影响很小的存储中。 另有些应用程序需要以文件形式注入的只读数据,比如配置数据或密钥。 _临时卷_ 就是为此类用例设计的。因为卷会遵从 Pod 的生命周期,与 Pod 一起创建和删除, 所以停止和重新启动 Pod 时,不会受持久卷在何处可用的限制。 临时卷在 Pod 规范中以 _内联_ 方式定义,这简化了应用程序的部署和管理。 ### 临时卷的类型 {#types-of-ephemeral-volumes} Kubernetes 为了不同的目的,支持几种不同类型的临时卷: - [emptyDir](/zh/docs/concepts/storage/volumes/#emptydir): Pod 启动时为空,存储空间来自本地的 kubelet 根目录(通常是根磁盘)或内存 - [configMap](/zh/docs/concepts/storage/volumes/#configmap)、 [downwardAPI](/zh/docs/concepts/storage/volumes/#downwardapi)、 [secret](/zh/docs/concepts/storage/volumes/#secret): 将不同类型的 Kubernetes 数据注入到 Pod 中 - [CSI 临时卷](/zh/docs/concepts/storage/volumes/#csi-ephemeral-volumes): 类似于前面的卷类型,但由专门[支持此特性](https://kubernetes-csi.github.io/docs/drivers.html) 的指定 [CSI 驱动程序](https://github.com/container-storage-interface/spec/blob/master/spec.md)提供 - [通用临时卷](#generic-ephemeral-volumes): 它可以由所有支持持久卷的存储驱动程序提供 `emptyDir`、`configMap`、`downwardAPI`、`secret` 是作为 [本地临时存储](/zh/docs/concepts/configuration/manage-resources-containers/#local-ephemeral-storage) 提供的。它们由各个节点上的 kubelet 管理。 CSI 临时卷 *必须* 由第三方 CSI 存储驱动程序提供。 通用临时卷 *可以* 由第三方 CSI 存储驱动程序提供,也可以由支持动态配置的任何其他存储驱动程序提供。 一些专门为 CSI 临时卷编写的 CSI 驱动程序,不支持动态供应:因此这些驱动程序不能用于通用临时卷。 使用第三方驱动程序的优势在于,它们可以提供 Kubernetes 本身不支持的功能, 例如,与 kubelet 管理的磁盘具有不同运行特征的存储,或者用来注入不同的数据 ### CSI 临时卷 {#csi-ephemeral-volumes} {{< feature-state for_k8s_version=\"v1.16\" state=\"beta\" >}} 该特性需要启用参数 `CSIInlineVolume` [特性门控(feature gate)](/zh/docs/reference/command-line-tools-reference/feature-gates/)。 该参数从 Kubernetes 1.16 开始默认启用。 {{< note >}} 只有一部分 CSI 驱动程序支持 CSI 临时卷。Kubernetes CSI [驱动程序列表](https://kubernetes-csi.github.io/docs/drivers.html) 显示了支持临时卷的驱动程序。 {{< /note >}} 从概念上讲,CSI 临时卷类似于 `configMap`、`downwardAPI` 和 `secret` 类型的卷: 其存储在每个节点本地管理,并在将 Pod 调度到节点后与其他本地资源一起创建。 在这个阶段,Kubernetes 没有重新调度 Pods 的概念。卷创建不太可能失败,否则 Pod 启动将会受阻。 特别是,这些卷 *不* 支持[感知存储容量的 Pod 调度](/zh/docs/concepts/storage/storage-capacity/)。 它们目前也没包括在 Pod 的存储资源使用限制中,因为 kubelet 只能对它自己管理的存储强制执行。 下面是使用 CSI 临时存储的 Pod 的示例清单: ```yaml kind: Pod apiVersion: v1 metadata: name: my-csi-app spec: containers: - name: my-frontend image: busybox volumeMounts: - mountPath: \"/data\" name: my-csi-inline-vol command: [ \"sleep\", \"1000000\" ] volumes: - name: my-csi-inline-vol csi: driver: inline.storage.kubernetes.io volumeAttributes: foo: bar ``` `volumeAttributes` 决定驱动程序准备什么样的卷。这些属性特定于每个驱动程序,且没有实现标准化。 有关进一步的说明,请参阅每个 CSI 驱动程序的文档。 作为一个集群管理员,你可以使用 [PodSecurityPolicy](/zh/docs/concepts/policy/pod-security-policy/) 来控制在 Pod 中可以使用哪些 CSI 驱动程序, 具体则是通过 [`allowedCSIDrivers` 字段](/docs/reference/generated/kubernetes-api/{{< param \"version\" >}}/#podsecuritypolicyspec-v1beta1-policy) 指定。 ### 通用临时卷 {#generic-ephemeral-volumes} {{< feature-state for_k8s_version=\"v1.19\" state=\"alpha\" >}} 这个特性需要启用 `GenericEphemeralVolume` [特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)。 因为这是一个alpha特性,默认禁用。 通用临时卷类似于 `emptyDir` 卷,但更加灵活: - 存储可以是本地的,也可以是网络连接的。 - 卷可以有固定的大小,pod不能超量使用。 - 卷可能有一些初始数据,这取决于驱动程序和参数。 - 当驱动程序支持,卷上的典型操作将被支持,包括([快照](/zh/docs/concepts/storage/volume-snapshots/)、[克隆](/zh/docs/concepts/storage/volume-pvc-datasource/)、[调整大小](/zh/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims)和[存储容量跟踪](/zh/docs/concepts/storage/storage-capacity/))。 示例: ```yaml kind: Pod apiVersion: v1 metadata: name: my-app spec: containers: - name: my-frontend image: busybox volumeMounts: - mountPath: \"/scratch\" name: scratch-volume command: [ \"sleep\", \"1000000\" ] volumes: - name: scratch-volume ephemeral: volumeClaimTemplate: metadata: labels: type: my-frontend-volume spec: accessModes: [ \"ReadWriteOnce\" ] storageClassName: \"scratch-storage-class\" resources: requests: storage: 1Gi ``` ### 生命周期和 PersistentVolumeClaim {#lifecycle-and-persistentvolumeclaim} 关键的设计思想是在 Pod 的卷来源中允许使用 [卷申领的参数](/docs/reference/generated/kubernetes-api/#ephemeralvolumesource-v1alpha1-core)。 PersistentVolumeClaim 的标签、注解和整套字段集均被支持。 创建这样一个 Pod 后, 临时卷控制器在 Pod 所属的命名空间中创建一个实际的 PersistentVolumeClaim 对象, 并确保删除 Pod 时, 同步删除PersistentVolumeClaim 。 如上设置将触发卷的绑定与/或准备操作,相应动作或者在 {{< glossary_tooltip text=\"StorageClass\" term_id=\"storage-class\" >}} 使用即时卷绑定时立即执行, 或者当 Pod 被暂时性调度到某节点时执行 (`WaitForFirstConsumer` 卷绑定模式)。 对于常见的临时卷,建议采用后者,这样调度器就可以自由地为 Pod 选择合适的节点。 对于即时绑定,调度器则必须选出一个节点,使得在卷可用时,能立即访问该卷。 就[资源所有权](/zh/docs/concepts/workloads/controllers/garbage-collection/#owners-and-dependents)而言, 拥有通用临时存储的 Pod 是提供临时存储 (ephemeral storage) 的 PersistentVolumeClaim 的所有者。 当 Pod 被删除时,Kubernetes 垃圾收集器会删除 PVC, 然后 PVC 通常会触发卷的删除,因为存储类的默认回收策略是删除卷。 你可以使用带有 `retain` 回收策略的 StorageClass 创建准临时 (quasi-ephemeral) 本地存储: 该存储比 Pod 寿命长,在这种情况下,你需要确保单独进行卷清理。 当这些 PVC 存在时,它们可以像其他 PVC 一样使用。 特别是,它们可以被引用作为批量克隆或快照的数据源。 PVC对象还保持着卷的当前状态。 ### PersistentVolumeClaim 的命名 {#persistentvolumeclaim-naming} 自动创建的 PVCs 的命名是确定的:此名称是 Pod 名称和卷名称的组合,中间由连字符(`-`)连接。 在上面的示例中,PVC 将命名为 `my-app-scratch-volume` 。 这种确定性命名方式使得与 PVC 交互变得更容易,因为一旦知道 Pod 名称和卷名,就不必搜索它。 这种确定性命名方式也引入了潜在的冲突, 比如在不同的 Pod 之间(名为 “Pod-a” 的 Pod 挂载名为 \"scratch\" 的卷, 名为 \"pod\" 的 Pod 挂载名为 “a-scratch” 的卷,这两者均会生成名为 \"pod-a-scratch\" 的PVC), 或者在 Pod 和手工创建的 PVC 之间。 以下冲突会被检测到:如果 PVC 是为 Pod 创建的,那么它只用于临时卷。 此检测基于所有权关系。现有的 PVC 不会被覆盖或修改。 但这并不能解决冲突,因为如果没有正确的 PVC,Pod 就无法启动。 {{< caution >}} 当命名 Pods 和卷出现在同一个命名空间中时,要小心,以防止发生此类冲突。 {{< /caution >}} ### 安全 {#security} 启用 GenericEphemeralVolume 特性会导致那些没有 PVCs 创建权限的用户, 在创建 Pods 时,被允许间接的创建 PVCs。 集群管理员必须意识到这一点。 如果这不符合他们的安全模型,他们有两种选择: - 通过特性门控显式禁用该特性,可以避免将来的 Kubernetes 版本默认启用时带来混乱。 - 当`卷`列表不包含 `ephemeral` 卷类型时,使用 [Pod 安全策略](/zh/docs/concepts/policy/pod-security-policy/)。 在一个命名空间中,用于 PVCs 的常规命名空间配额仍然适用, 因此即使允许用户使用这种新机制,他们也不能使用它来规避其他策略。 ## {{% heading \"whatsnext\" %}} ### kubelet 管理的临时卷 {#ephemeral-volumes-managed-by-kubelet} 参阅[本地临时存储](/zh/docs/concepts/configuration/manage-resources-containers/#local-ephemeral-storage)。 ### CSI 临时卷 {#csi-ephemeral-volumes} - 有关设计的更多信息,参阅 [Ephemeral Inline CSI volumes KEP](https://github.com/kubernetes/enhancements/blob/ad6021b3d61a49040a3f835e12c8bb5424db2bbb/keps/sig-storage/20190122-csi-inline-volumes.md)。 - 本特性下一步开发的更多信息,参阅 [enhancement tracking issue #596](https://github.com/kubernetes/enhancements/issues/596)。 ### 通用临时卷 {#generic-ephemeral-volumes} - 有关设计的更多信息,参阅 [Generic ephemeral inline volumes KEP](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/1698-generic-ephemeral-volumes/README.md)。 - 本特性下一步开发的更多信息,参阅 [enhancement tracking issue #1698](https://github.com/kubernetes/enhancements/issues/1698). No newline at end of file"} {"_id":"q-en-website-1637248fb2847514e29f4d1eac0726384ce5af1dd8420a1d76f990e459c7cef6","text":"name: game-config namespace: default resourceVersion: \"516\" selfLink: /api/v1/namespaces/default/configmaps/game-config-2 selfLink: /api/v1/namespaces/default/configmaps/game-config uid: b4952dc3-d670-11e5-8cd0-68f728db1985 ```"} {"_id":"q-en-website-174492f5288b30d380780d6139bfeb1171fd07c5928c6113b3c116e723e572c6","text":"placement policies while keeping the abstraction free from explicit placement directives. For detailed information on resource management, please refer to the [Resource Management for Pods and Containers](/docs/concepts/configuration/manage-resources-containers) documentation. ## {{% heading \"prerequisites\" %}}"} {"_id":"q-en-website-17b6380a62a23b3de2deede9ddc35c9a9b79fa8e7086dc58af58bf40ccd17a18","text":"### Docker 1. 在每个节点上,根据[安装 Docker 引擎](https://docs.docker.com/engine/install/#server) 为你的 Linux 发行版安装 Docker。"} {"_id":"q-en-website-192092393a6877573c512db2382361ae58776b93bfeb174b5cd80c73d1980a55","text":"| strategic-merge-patch | The new endpoints support PATCH with `Content-Type: application/strategic-merge-patch+json`. Useful for updating objects that may be modified both locally, and by the server. For more information, see [\"Update API Objects in Place Using kubectl patch\"](/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/) | No | Yes | | Protocol Buffers | The new resource supports clients that want to use Protocol Buffers | No | Yes | | OpenAPI Schema | Is there an OpenAPI (swagger) schema for the types that can be dynamically fetched from the server? Is the user protected from misspelling field names by ensuring only allowed fields are set? Are types enforced (in other words, don't put an `int` in a `string` field?) | Yes, based on the [OpenAPI v3.0 validation](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation) schema (GA in 1.16). | Yes | | Instance Name | Does this extension mechanism impose any constraints on the names of objects whose kind/resource is defined this way? | Yes, such an object's name must be a valid DNS subdomain name. | No | ### Common Features"} {"_id":"q-en-website-194c2e4035ee5a3cfccfce9da5238683c87e77bf323c5d9108440691cdb90f2c","text":"### Volume snapshot If etcd is running on a storage volume that supports backup, such as Amazon Elastic Block Store, back up etcd data by taking a snapshot of the storage volume. If etcd is running on a storage volume that supports backup, such as Amazon Elastic Block Store, back up etcd data by taking a snapshot of the storage volume. ## Scaling up etcd clusters Scaling up etcd clusters increases availability by trading off performance. Scaling does not increase cluster performance nor capability. A general rule is not to scale up or down etcd clusters. Do not configure any auto scaling groups for etcd clusters. It is highly recommended to always run a static five-member etcd cluster for production Kubernetes clusters at any officially supported scale. Scaling up etcd clusters increases availability by trading off performance. Scaling does not increase cluster performance nor capability. A general rule is not to scale up or down etcd clusters. Do not configure any auto scaling groups for etcd clusters. It is highly recommended to always run a static five-member etcd cluster for production Kubernetes clusters at any officially supported scale. A reasonable scaling is to upgrade a three-member cluster to a five-member one, when more reliability is desired. See [etcd Reconfiguration Documentation](https://github.com/coreos/etcd/blob/master/Documentation/op-guide/runtime-configuration.md#remove-a-member) for information on how to add members into an existing cluster. A reasonable scaling is to upgrade a three-member cluster to a five-member one, when more reliability is desired. See [etcd reconfiguration documentation](https://etcd.io/docs/current/op-guide/runtime-configuration/#remove-a-member) for information on how to add members into an existing cluster. ## Restoring an etcd cluster etcd supports restoring from snapshots that are taken from an etcd process of the [major.minor](http://semver.org/) version. Restoring a version from a different patch version of etcd also is supported. A restore operation is employed to recover the data of a failed cluster. Before starting the restore operation, a snapshot file must be present. It can either be a snapshot file from a previous backup operation, or from a remaining [data directory](https://github.com/coreos/etcd/blob/master/Documentation/op-guide/configuration.md#--data-dir). For more information and examples on restoring a cluster from a snapshot file, see [etcd disaster recovery documentation](https://github.com/coreos/etcd/blob/master/Documentation/op-guide/recovery.md#restoring-a-cluster). If the access URLs of the restored cluster is changed from the previous cluster, the Kubernetes API server must be reconfigured accordingly. In this case, restart Kubernetes API server with the flag `--etcd-servers=$NEW_ETCD_CLUSTER` instead of the flag `--etcd-servers=$OLD_ETCD_CLUSTER`. Replace `$NEW_ETCD_CLUSTER` and `$OLD_ETCD_CLUSTER` with the respective IP addresses. If a load balancer is used in front of an etcd cluster, you might need to update the load balancer instead. If the majority of etcd members have permanently failed, the etcd cluster is considered failed. In this scenario, Kubernetes cannot make any changes to its current state. Although the scheduled pods might continue to run, no new pods can be scheduled. In such cases, recover the etcd cluster and potentially reconfigure Kubernetes API server to fix the issue. etcd supports restoring from snapshots that are taken from an etcd process of the [major.minor](http://semver.org/) version. Restoring a version from a different patch version of etcd also is supported. A restore operation is employed to recover the data of a failed cluster. Before starting the restore operation, a snapshot file must be present. It can either be a snapshot file from a previous backup operation, or from a remaining [data directory]( https://etcd.io/docs/current/op-guide/configuration/#--data-dir). For more information and examples on restoring a cluster from a snapshot file, see [etcd disaster recovery documentation](https://etcd.io/docs/current/op-guide/recovery/#restoring-a-cluster). If the access URLs of the restored cluster is changed from the previous cluster, the Kubernetes API server must be reconfigured accordingly. In this case, restart Kubernetes API servers with the flag `--etcd-servers=$NEW_ETCD_CLUSTER` instead of the flag `--etcd-servers=$OLD_ETCD_CLUSTER`. Replace `$NEW_ETCD_CLUSTER` and `$OLD_ETCD_CLUSTER` with the respective IP addresses. If a load balancer is used in front of an etcd cluster, you might need to update the load balancer instead. If the majority of etcd members have permanently failed, the etcd cluster is considered failed. In this scenario, Kubernetes cannot make any changes to its current state. Although the scheduled pods might continue to run, no new pods can be scheduled. In such cases, recover the etcd cluster and potentially reconfigure Kubernetes API servers to fix the issue. {{< note >}} If any API servers are running in your cluster, you should not attempt to restore instances of etcd. Instead, follow these steps to restore etcd: If any API servers are running in your cluster, you should not attempt to restore instances of etcd. Instead, follow these steps to restore etcd: - stop *all* kube-apiserver instances - stop *all* API server instances - restore state in all etcd instances - restart all kube-apiserver instances - restart all API server instances We also recommend restarting any components (e.g. kube-scheduler, kube-controller-manager, kubelet) to ensure that they don't rely on some stale data. Note that in practice, the restore takes a bit of time. During the restoration, critical components will lose leader lock and restart themselves. We also recommend restarting any components (e.g. `kube-scheduler`, `kube-controller-manager`, `kubelet`) to ensure that they don't rely on some stale data. Note that in practice, the restore takes a bit of time. During the restoration, critical components will lose leader lock and restart themselves. {{< /note >}} ## Upgrading and rolling back etcd clusters As of Kubernetes v1.13.0, etcd2 is no longer supported as a storage backend for new or existing Kubernetes clusters. The timeline for Kubernetes support for etcd2 and etcd3 is as follows: - Kubernetes v1.0: etcd2 only - Kubernetes v1.5.1: etcd3 support added, new clusters still default to etcd2 - Kubernetes v1.6.0: new clusters created with `kube-up.sh` default to etcd3, and `kube-apiserver` defaults to etcd3 - Kubernetes v1.9.0: deprecation of etcd2 storage backend announced - Kubernetes v1.13.0: etcd2 storage backend removed, `kube-apiserver` will refuse to start with `--storage-backend=etcd2`, with the message `etcd2 is no longer a supported storage backend` Before upgrading a v1.12.x kube-apiserver using `--storage-backend=etcd2` to v1.13.x, etcd v2 data must be migrated to the v3 storage backend and kube-apiserver invocations must be changed to use `--storage-backend=etcd3`. The process for migrating from etcd2 to etcd3 is highly dependent on how the etcd cluster was deployed and configured, as well as how the Kubernetes cluster was deployed and configured. We recommend that you consult your cluster provider's documentation to see if there is a predefined solution. If your cluster was created via `kube-up.sh` and is still using etcd2 as its storage backend, please consult the [Kubernetes v1.12 etcd cluster upgrade docs](https://v1-12.docs.kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/#upgrading-and-rolling-back-etcd-clusters) ## Known issue: etcd client balancer with secure endpoints The etcd v3 client, released in etcd v3.3.13 or earlier, has a [critical bug](https://github.com/kubernetes/kubernetes/issues/72102) which affects the kube-apiserver and HA deployments. The etcd client balancer failover does not properly work against secure endpoints. As a result, etcd servers may fail or disconnect briefly from the kube-apiserver. This affects kube-apiserver HA deployments. The fix was made in [etcd v3.4](https://github.com/etcd-io/etcd/pull/10911) (and backported to v3.3.14 or later): the new client now creates its own credential bundle to correctly set authority target in dial function. Because the fix requires gRPC dependency upgrade (to v1.23.0), downstream Kubernetes [did not backport etcd upgrades](https://github.com/kubernetes/kubernetes/issues/72102#issuecomment-526645978). Which means the [etcd fix in kube-apiserver](https://github.com/etcd-io/etcd/pull/10911/commits/db61ee106ca9363ba3f188ecf27d1a8843da33ab) is only available from Kubernetes 1.16. To urgently fix this bug for Kubernetes 1.15 or earlier, build a custom kube-apiserver. You can make local changes to [`vendor/google.golang.org/grpc/credentials/credentials.go`](https://github.com/kubernetes/kubernetes/blob/7b85be021cd2943167cd3d6b7020f44735d9d90b/vendor/google.golang.org/grpc/credentials/credentials.go#L135) with [etcd@db61ee106](https://github.com/etcd-io/etcd/pull/10911/commits/db61ee106ca9363ba3f188ecf27d1a8843da33ab). See [\"kube-apiserver 1.13.x refuses to work when first etcd-server is not available\"](https://github.com/kubernetes/kubernetes/issues/72102). "} {"_id":"q-en-website-197b1e8bd8f87194941b7c4efc822d45dd3d52e532f959d6e8079839a2f403bf","text":"* [vsphereVolume](/docs/concepts/storage/volumes/#vspherevolume) ##### FlexVolume Plugins Code associated with [FlexVolume](/docs/concepts/storage/volumes/#flexVolume) plugins ship as out-of-tree scripts or binaries that need to be deployed directly on the host. FlexVolume plugins handle attaching/detaching of volumes to/from a Kubernetes node and mounting/dismounting a volume to/from individual containers in a pod. Provisioning/De-provisioning of persistent volumes associated with FlexVolume plugins may be handled through an external provisioner that is typically separate from the FlexVolume plugins. The following FlexVolume [plugins](https://github.com/Microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows), deployed as powershell scripts on the host, support Windows nodes: [FlexVolume](/docs/concepts/storage/volumes/#flexVolume)プラグインに関連付けられたコードは、ホストに直接デプロイする必要があるout-of-treeのスクリプトまたはバイナリとして出荷されます。FlexVolumeプラグインは、Kubernetesノードとの間のボリュームのアタッチ/デタッチ、およびPod内の個々のコンテナとの間のボリュームのマウント/マウント解除を処理します。FlexVolumeプラグインに関連付けられた永続ボリュームのプロビジョニング/プロビジョニング解除は、通常FlexVolumeプラグインとは別の外部プロビジョニング担当者を通じて処理できます。次のFlexVolume[プラグイン](https://github.com/Microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows)は、Powershellスクリプトとしてホストにデプロイされ、Windowsノードをサポートします。: * [SMB](https://github.com/microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows/plugins/microsoft.com~smb.cmd) * [iSCSI](https://github.com/microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows/plugins/microsoft.com~iscsi.cmd) ##### CSI Plugins ##### CSIプラグイン {{< feature-state for_k8s_version=\"v1.16\" state=\"alpha\" >}} Code associated with {{< glossary_tooltip text=\"CSI\" term_id=\"csi\" >}} plugins ship as out-of-tree scripts and binaries that are typically distributed as container images and deployed using standard Kubernetes constructs like DaemonSets and StatefulSets. CSI plugins handle a wide range of volume management actions in Kubernetes: provisioning/de-provisioning/resizing of volumes, attaching/detaching of volumes to/from a Kubernetes node and mounting/dismounting a volume to/from individual containers in a pod, backup/restore of persistent data using snapshots and cloning. CSI plugins typically consist of node plugins (that run on each node as a DaemonSet) and controller plugins. {{< glossary_tooltip text=\"CSI\" term_id=\"csi\" >}}プラグインに関連付けられたコードは、通常、コンテナイメージとして配布され、DaemonSetsやStatefulSetsなどの標準のKubernetesコンポーネントを使用してデプロイされるout-of-treeのスクリプトおよびバイナリとして出荷されます。CSIプラグインは、Kubernetesの幅広いボリューム管理アクションを処理します:ボリュームのプロビジョニング/プロビジョニング解除/サイズ変更、Kubernetesノードへのボリュームのアタッチ/ボリュームからのデタッチ、Pod内の個々のコンテナへのボリュームのマウント/マウント解除、バックアップ/スナップショットとクローニングを使用した永続データのバックアップ/リストア。CSIプラグインは通常、ノードプラグイン(各ノードでDaemonSetとして実行される)とコントローラープラグインで構成されます。 CSI node plugins (especially those associated with persistent volumes exposed as either block devices or over a shared file-system) need to perform various privileged operations like scanning of disk devices, mounting of file systems, etc. These operations differ for each host operating system. For Linux worker nodes, containerized CSI node plugins are typically deployed as privileged containers. For Windows worker nodes, privileged operations for containerized CSI node plugins is supported using [csi-proxy](https://github.com/kubernetes-csi/csi-proxy), a community-managed, stand-alone binary that needs to be pre-installed on each Windows node. Please refer to the deployment guide of the CSI plugin you wish to deploy for further details. CSIノードプラグイン(特に、ブロックデバイスまたは共有ファイルシステムとして公開された永続ボリュームに関連付けられているプラ​​グイン)は、ディスクデバイスのスキャン、ファイルシステムのマウントなど、さまざまな特権操作を実行する必要があります。これらの操作は、ホストオペレーティングシステムごとに異なります。Linuxワーカーノードの場合、コンテナ化されたCSIノードプラグインは通常、特権コンテナとしてデプロイされます。Windowsワーカーノードの場合、コンテナ化されたCSIノードプラグインの特権操作は、[csi-proxy](https://github.com/kubernetes-csi/csi-proxy)を使用してサポートされます。各Windowsノードにプリインストールされている。詳細については、展開するCSIプラグインの展開ガイドを参照してください。 #### Networking #### ネットワーキング Networking for Windows containers is exposed through [CNI plugins](/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/). Windows containers function similarly to virtual machines in regards to networking. Each container has a virtual network adapter (vNIC) which is connected to a Hyper-V virtual switch (vSwitch). The Host Networking Service (HNS) and the Host Compute Service (HCS) work together to create containers and attach container vNICs to networks. HCS is responsible for the management of containers whereas HNS is responsible for the management of networking resources such as: Windowsコンテナのネットワークは、[CNIプラグイン](/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)を通じて公開されます。Windowsコンテナは、ネットワークに関して仮想マシンと同様に機能します。各コンテナには、Hyper-V仮想スイッチ(vSwitch)に接続されている仮想ネットワークアダプター(vNIC)があります。Host Network Service(HNS)とHost Compute Service(HCS)は連携してコンテナを作成し、コンテナvNICをネットワークに接続します。HCSはコンテナの管理を担当するのに対し、HNSは次のようなネットワークリソースの管理を担当します。: * Virtual networks (including creation of vSwitches) * Endpoints / vNICs * Namespaces * Policies (Packet encapsulations, Load-balancing rules, ACLs, NAT'ing rules, etc.) * 仮想ネットワーク(vSwitchの作成を含む) * エンドポイント/vNIC * ネームスペース * ポリシー(パケットのカプセル化、負荷分散ルール、ACL、NATルールなど) The following service spec types are supported: 次のServiceタイプがサポートされています。: * NodePort * ClusterIP * LoadBalancer * ExternalName Windows supports five different networking drivers/modes: L2bridge, L2tunnel, Overlay, Transparent, and NAT. In a heterogeneous cluster with Windows and Linux worker nodes, you need to select a networking solution that is compatible on both Windows and Linux. The following out-of-tree plugins are supported on Windows, with recommendations on when to use each CNI: Windowsは、L2bridge、L2tunnel、Overlay、Transparent、NATの5つの異なるネットワークドライバー/モードをサポートしています。WindowsとLinuxのワーカーノードを持つ異種クラスターでは、WindowsとLinuxの両方で互換性のあるネットワークソリューションを選択する必要があります。以下のツリー外プラグインがWindowsでサポートされており、各CNIをいつ使用するかに関する推奨事項があります。: | Network Driver | Description | Container Packet Modifications | Network Plugins | Network Plugin Characteristics | | ネットワークドライバー | 説明 | コンテナパケットの変更 | ネットワークプラグイン | ネットワークプラグインの特性 | | -------------- | ----------- | ------------------------------ | --------------- | ------------------------------ | | L2bridge | Containers are attached to an external vSwitch. Containers are attached to the underlay network, although the physical network doesn't need to learn the container MACs because they are rewritten on ingress/egress. Inter-container traffic is bridged inside the container host. | MAC is rewritten to host MAC, IP remains the same. | [win-bridge](https://github.com/containernetworking/plugins/tree/master/plugins/main/windows/win-bridge), [Azure-CNI](https://github.com/Azure/azure-container-networking/blob/master/docs/cni.md), Flannel host-gateway uses win-bridge | win-bridge uses L2bridge network mode, connects containers to the underlay of hosts, offering best performance. Requires user-defined routes (UDR) for inter-node connectivity. | | L2Tunnel | This is a special case of l2bridge, but only used on Azure. All packets are sent to the virtualization host where SDN policy is applied. | MAC rewritten, IP visible on the underlay network | [Azure-CNI](https://github.com/Azure/azure-container-networking/blob/master/docs/cni.md) | Azure-CNI allows integration of containers with Azure vNET, and allows them to leverage the set of capabilities that [Azure Virtual Network provides](https://azure.microsoft.com/en-us/services/virtual-network/). For example, securely connect to Azure services or use Azure NSGs. See [azure-cni for some examples](https://docs.microsoft.com/en-us/azure/aks/concepts-network#azure-cni-advanced-networking) | | Overlay (Overlay networking for Windows in Kubernetes is in *alpha* stage) | Containers are given a vNIC connected to an external vSwitch. Each overlay network gets its own IP subnet, defined by a custom IP prefix.The overlay network driver uses VXLAN encapsulation. | Encapsulated with an outer header. | [Win-overlay](https://github.com/containernetworking/plugins/tree/master/plugins/main/windows/win-overlay), Flannel VXLAN (uses win-overlay) | win-overlay should be used when virtual container networks are desired to be isolated from underlay of hosts (e.g. for security reasons). Allows for IPs to be re-used for different overlay networks (which have different VNID tags) if you are restricted on IPs in your datacenter. This option requires [KB4489899](https://support.microsoft.com/help/4489899) on Windows Server 2019. | | Transparent (special use case for [ovn-kubernetes](https://github.com/openvswitch/ovn-kubernetes)) | Requires an external vSwitch. Containers are attached to an external vSwitch which enables intra-pod communication via logical networks (logical switches and routers). | Packet is encapsulated either via [GENEVE](https://datatracker.ietf.org/doc/draft-gross-geneve/) or [STT](https://datatracker.ietf.org/doc/draft-davie-stt/) tunneling to reach pods which are not on the same host.
Packets are forwarded or dropped via the tunnel metadata information supplied by the ovn network controller.
NAT is done for north-south communication. | [ovn-kubernetes](https://github.com/openvswitch/ovn-kubernetes) | [Deploy via ansible](https://github.com/openvswitch/ovn-kubernetes/tree/master/contrib). Distributed ACLs can be applied via Kubernetes policies. IPAM support. Load-balancing can be achieved without kube-proxy. NATing is done without using iptables/netsh. | | NAT (*not used in Kubernetes*) | Containers are given a vNIC connected to an internal vSwitch. DNS/DHCP is provided using an internal component called [WinNAT](https://blogs.technet.microsoft.com/virtualization/2016/05/25/windows-nat-winnat-capabilities-and-limitations/) | MAC and IP is rewritten to host MAC/IP. | [nat](https://github.com/Microsoft/windows-container-networking/tree/master/plugins/nat) | Included here for completeness |
| L2bridge | コンテナは外部のvSwitchに接続されます。コンテナはアンダーレイネットワークに接続されますが、物理ネットワークはコンテナのMACを上り/下りで書き換えるため、MACを学習する必要はありません。コンテナ間トラフィックは、コンテナホスト内でブリッジされます。 | MACはホストのMACに書き換えられ、IPは変わりません。| [win-bridge](https://github.com/containernetworking/plugins/tree/master/plugins/main/windows/win-bridge)、[Azure-CNI](https://github.com/Azure/azure-container-networking/blob/master/docs/cni.md)、Flannelホストゲートウェイは、win-bridgeを使用します。 | win-bridgeはL2bridgeネットワークモードを使用して、コンテナをホストのアンダーレイに接続して、最高のパフォーマンスを提供します。ノード間接続にはユーザー定義ルート(UDR)が必要です。 | | L2Tunnel | これはl2bridgeの特殊なケースですが、Azureでのみ使用されます。すべてのパケットは、SDNポリシーが適用されている仮想化ホストに送信されます。| MACが書き換えられ、IPがアンダーレイネットワークで表示されます。 | [Azure-CNI](https://github.com/Azure/azure-container-networking/blob/master/docs/cni.md) | Azure-CNIを使用すると、コンテナをAzure vNETと統合し、[Azure Virtual Networkが提供](https://azure.microsoft.com/en-us/services/virtual-network/)する一連の機能を活用できます。たとえば、Azureサービスに安全に接続するか、Azure NSGを使用します。[azure-cniのいくつかの例](https://docs.microsoft.com/en-us/azure/aks/concepts-network#azure-cni-advanced-networking)を参照してください。| | オーバーレイ(KubernetesのWindows用のオーバーレイネットワークは *アルファ* 段階です)| コンテナには、外部のvSwitchに接続されたvNICが付与されます。各オーバーレイネットワークは、カスタムIPプレフィックスで定義された独自のIPサブネットを取得します。オーバーレイネットワークドライバーは、VXLANを使用してカプセル化します。 | 外部ヘッダーでカプセル化されます。 | [Win-overlay](https://github.com/containernetworking/plugins/tree/master/plugins/main/windows/win-overlay)、Flannel VXLAN (win-overlayを使用) | win-overlayは、仮想コンテナーネットワークをホストのアンダーレイから分離する必要がある場合に使用する必要があります(セキュリティ上の理由など)。データセンター内のIPが制限されている場合に、(異なるVNIDタグを持つ)異なるオーバーレイネットワークでIPを再利用できるようにします。このオプションには、Windows Server 2019で[KB4489899](https://support.microsoft.com/help/4489899)が必要です。| | 透過的([ovn-kubernetes](https://github.com/openvswitch/ovn-kubernetes)の特別な使用例) | 外部のvSwitchが必要です。コンテナは外部のvSwitchに接続され、論理ネットワーク(論理スイッチおよびルーター)を介したPod内通信を可能にします。 | パケットは、[GENEVE](https://datatracker.ietf.org/doc/draft-gross-geneve/)または[STT](https://datatracker.ietf.org/doc/draft-davie-stt/)トンネリングを介してカプセル化され、同じホスト上にないポッドに到達します。パケットは、ovnネットワークコントローラーによって提供されるトンネルメタデータ情報を介して転送またはドロップされます。NATは南北通信のために行われます。 | [ovn-kubernetes](https://github.com/openvswitch/ovn-kubernetes) | [ansible経由でデプロイ](https://github.com/openvswitch/ovn-kubernetes/tree/master/contrib)します。分散ACLは、Kubernetesポリシーを介して適用できます。 IPAMをサポートします。負荷分散は、kube-proxyなしで実現できます。 NATは、ip​​tables/netshを使用せずに行われます。 | | NAT(*Kubernetesでは使用されません*) | コンテナには、内部のvSwitchに接続されたvNICが付与されます。DNS/DHCPは、[WinNAT](https://blogs.technet.microsoft.com/virtualization/2016/05/25/windows-nat-winnat-capabilities-and-limitations/)と呼ばれる内部コンポーネントを使用して提供されます。 | MACおよびIPはホストMAC/IPに書き換えられます。 | [nat](https://github.com/Microsoft/windows-container-networking/tree/master/plugins/nat) | 完全を期すためにここに含まれています。 | As outlined above, the [Flannel](https://github.com/coreos/flannel) CNI [meta plugin](https://github.com/containernetworking/plugins/tree/master/plugins/meta/flannel) is also supported on [Windows](https://github.com/containernetworking/plugins/tree/master/plugins/meta/flannel#windows-support-experimental) via the [VXLAN network backend](https://github.com/coreos/flannel/blob/master/Documentation/backends.md#vxlan) (**alpha support** ; delegates to win-overlay) and [host-gateway network backend](https://github.com/coreos/flannel/blob/master/Documentation/backends.md#host-gw) (stable support; delegates to win-bridge). This plugin supports delegating to one of the reference CNI plugins (win-overlay, win-bridge), to work in conjunction with Flannel daemon on Windows (Flanneld) for automatic node subnet lease assignment and HNS network creation. This plugin reads in its own configuration file (cni.conf), and aggregates it with the environment variables from the FlannelD generated subnet.env file. It then delegates to one of the reference CNI plugins for network plumbing, and sends the correct configuration containing the node-assigned subnet to the IPAM plugin (e.g. host-local). 上で概説したように、[Flannel](https://github.com/coreos/flannel) CNI[メタプラグイン](https://github.com/containernetworking/plugins/tree/master/plugins/meta/flannel)は、[VXLANネットワークバックエンド](https://github.com/coreos/flannel/blob/master/Documentation/backends.md#vxlan)(**アルファサポート**、win-overlayへのデリゲート)および[ホストゲートウェイネットワークバックエンド](https://github.com/coreos/flannel/blob/master/Documentation/backends.md#host-gw)(安定したサポート、win-bridgeへのデリゲート)を介して[Windows](https://github.com/containernetworking/plugins/tree/master/plugins/meta/flannel#windows-support-experimental)でもサポートされます。このプラグインは、参照CNIプラグイン(win-overlay、win-bridge)の1つへの委任をサポートし、WindowsのFlannelデーモン(Flanneld)と連携して、ノードのサブネットリースの自動割り当てとHNSネットワークの作成を行います。このプラグインは、独自の構成ファイル(cni.conf)を読み取り、FlannelDで生成されたsubnet.envファイルからの環境変数と統合します。次に、ネットワークプラミング用の参照CNIプラグインの1つに委任し、ノード割り当てサブネットを含む正しい構成をIPAMプラグイン(ホストローカルなど)に送信します。 For the node, pod, and service objects, the following network flows are supported for TCP/UDP traffic: Node、Pod、およびServiceオブジェクトの場合、TCP/UDPトラフィックに対して次のネットワークフローがサポートされます。: * Pod -> Pod (IP) * Pod -> Pod (Name) * Pod -> Service (Cluster IP) * Pod -> Service (PQDN, but only if there are no \".\") * Pod -> Service (PQDN、ただし、「.」がない場合のみ) * Pod -> Service (FQDN) * Pod -> External (IP) * Pod -> External (DNS) * Node -> Pod * Pod -> Node The following IPAM options are supported on Windows: Windowsでは、次のIPAMオプションがサポートされています。 * [Host-local](https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local) * HNS IPAM (Inbox platform IPAM, this is a fallback when no IPAM is set) * [Azure-vnet-ipam](https://github.com/Azure/azure-container-networking/blob/master/docs/ipam.md) (for azure-cni only) * [ホストローカル](https://github.com/containernetworking/plugins/tree/master/plugins/ipam/host-local) * HNS IPAM (受信トレイプラットフォームIPAM、これはIPAMが設定されていない場合のフォールバック) * [Azure-vnet-ipam](https://github.com/Azure/azure-container-networking/blob/master/docs/ipam.md)(azure-cniのみ) ### Limitations ### 制限 #### Control Plane #### コントロールプレーン Windows is only supported as a worker node in the Kubernetes architecture and component matrix. This means that a Kubernetes cluster must always include Linux master nodes, zero or more Linux worker nodes, and zero or more Windows worker nodes. Windowsは、Kubernetesアーキテクチャとコンポーネントマトリックスのワーカーノードとしてのみサポートされています。つまり、Kubernetesクラスタには常にLinuxマスターノード、0以上のLinuxワーカーノード、0以上のWindowsワーカーノードが含まれている必要があります。 #### Compute #### コンピュート ##### Resource management and process isolation ##### リソース管理とプロセス分離 Linux cgroups are used as a pod boundary for resource controls in Linux. Containers are created within that boundary for network, process and file system isolation. The cgroups APIs can be used to gather cpu/io/memory stats. In contrast, Windows uses a Job object per container with a system namespace filter to contain all processes in a container and provide logical isolation from the host. There is no way to run a Windows container without the namespace filtering in place. This means that system privileges cannot be asserted in the context of the host, and thus privileged containers are not available on Windows. Containers cannot assume an identity from the host because the Security Account Manager (SAM) is separate. Linux cgroupsは、Linuxのリソースを制御するPodの境界として使用されます。コンテナは、ネットワーク、プロセス、およびファイルシステムを分離するのために、その境界内に作成されます。cgroups APIを使用して、cpu/io/memoryの統計を収集できます。対照的に、Windowsはシステムネームスペースフィルターを備えたコンテナごとのジョブオブジェクトを使用して、コンテナ内のすべてのプロセスを格納し、ホストからの論理的な分離を提供します。ネームスペースフィルタリングを行わずにWindowsコンテナを実行する方法はありません。これは、ホストの環境ではシステム特権を主張できないため、Windowsでは特権コンテナを使用できないことを意味します。セキュリティアカウントマネージャー(SAM)が独立しているため、コンテナはホストからIDを引き受けることができません。 ##### Operating System Restrictions ##### オペレーティングシステムの制限 Windows has strict compatibility rules, where the host OS version must match the container base image OS version. Only Windows containers with a container operating system of Windows Server 2019 are supported. Hyper-V isolation of containers, enabling some backward compatibility of Windows container image versions, is planned for a future release. Windowsには厳密な互換性ルールがあり、ホストOSのバージョンとコンテナのベースイメージOSのバージョンは、一致する必要があります。Windows Server 2019のコンテナオペレーティングシステムを備えたWindowsコンテナのみがサポートされます。Hyper-V分離のコンテナは、Windowsコンテナのイメージバージョンに下位互換性を持たせることは、将来のリリースで計画されています。 ##### Feature Restrictions ##### 機能制限 * TerminationGracePeriod: not implemented * Single file mapping: to be implemented with CRI-ContainerD * Termination message: to be implemented with CRI-ContainerD * Privileged Containers: not currently supported in Windows containers * HugePages: not currently supported in Windows containers * The existing node problem detector is Linux-only and requires privileged containers. In general, we don't expect this to be used on Windows because privileged containers are not supported * Not all features of shared namespaces are supported (see API section for more details) * TerminationGracePeriod:実装されていません * 単一ファイルのマッピング:CRI-ContainerDで実装されます * 終了メッセージ:CRI-ContainerDで実装されます * 特権コンテナ:現在Windowsコンテナではサポートされていません * HugePages:現在Windowsコンテナではサポートされていません * 既存のノード問題を検出する機能はLinux専用であり、特権コンテナが必要です。一般的に、特権コンテナはサポートされていないため、これがWindowsで使用されることは想定していません。 * ネームスペース共有については、すべての機能がサポートされているわけではありません(詳細については、APIセクションを参照してください) ##### Memory Reservations and Handling ##### メモリ予約と処理 Windows does not have an out-of-memory process killer as Linux does. Windows always treats all user-mode memory allocations as virtual, and pagefiles are mandatory. The net effect is that Windows won't reach out of memory conditions the same way Linux does, and processes page to disk instead of being subject to out of memory (OOM) termination. If memory is over-provisioned and all physical memory is exhausted, then paging can slow down performance. Windowsには、Linuxのようなメモリ不足のプロセスキラーはありません。Windowsは常に全ユーザーモードのメモリ割り当てを仮想として扱い、ページファイルは必須です。正味の効果は、WindowsはLinuxのようなメモリ不足の状態にはならず、メモリ不足(OOM)終了の影響を受ける代わりにページをディスクに処理します。メモリが過剰にプロビジョニングされ、物理メモリのすべてが使い果たされると、ページングによってパフォーマンスが低下する可能性があります。 Keeping memory usage within reasonable bounds is possible with a two-step process. First, use the kubelet parameters `--kubelet-reserve` and/or `--system-reserve` to account for memory usage on the node (outside of containers). This reduces [NodeAllocatable](/ja/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)). As you deploy workloads, use resource limits (must set only limits or limits must equal requests) on containers. This also subtracts from NodeAllocatable and prevents the scheduler from adding more pods once a node is full. 2ステップのプロセスで、メモリ使用量を妥当な範囲内に保つことが可能です。まず、kubeletパラメータ`--kubelet-reserve`や`--system-reserve`を使用して、ノード(コンテナ外)でのメモリ使用量を明確にします。これにより、[NodeAllocatable](/ja/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable))が削減されます。ワークロードをデプロイするときは、コンテナにリソース制限をかけます(制限のみを設定するか、制限が要求と等しくなければなりません)。これにより、NodeAllocatableも差し引かれ、ノードのリソースがフルな状態になるとSchedulerがPodを追加できなくなります。 A best practice to avoid over-provisioning is to configure the kubelet with a system reserved memory of at least 2GB to account for Windows, Docker, and Kubernetes processes. 過剰なプロビジョニングを回避するためのベストプラクティスは、Windows、Docker、およびKubernetesのプロセスに対応するために、最低2GBのメモリを予約したシステムでkubeletを構成することです。 The behavior of the flags behave differently as described below: フラグの振舞いについては、次のような異なる動作をします。: * `--kubelet-reserve`, `--system-reserve` , and `--eviction-hard` flags update Node Allocatable * Eviction by using `--enforce-node-allocable` is not implemented * Eviction by using `--eviction-hard` and `--eviction-soft` are not implemented * MemoryPressure Condition is not implemented * There are no OOM eviction actions taken by the kubelet * Kubelet running on the windows node does not have memory restrictions. `--kubelet-reserve` and `--system-reserve` do not set limits on kubelet or processes running on the host. This means kubelet or a process on the host could cause memory resource starvation outside the node-allocatable and scheduler * `--kubelet-reserve`、`--system-reserve`、および`--eviction-hard`フラグはノードの割り当て可能数を更新します * `--enforce-node-allocable`を使用した排除は実装されていません * `--eviction-hard`および`--eviction-soft`を使用した排除は実装されていません * MemoryPressureの制約は実装されていません * kubeletによって実行されるOOMを排除することはありません * Windowsノードで実行されているKubeletにはメモリ制限がありません。`--kubelet-reserve`と`--system-reserve`は、ホストで実行されているkubeletまたはプロセスに制限を設定しません。これは、ホスト上のkubeletまたはプロセスが、NodeAllocatableとSchedulerの外でメモリリソース不足を引き起こす可能性があることを意味します。 #### Storage #### ストレージ Windows has a layered filesystem driver to mount container layers and create a copy filesystem based on NTFS. All file paths in the container are resolved only within the context of that container. Windowsには、コンテナレイヤーをマウントして、NTFSに基づいて複製されたファイルシステムを作るためのレイヤー構造のファイルシステムドライバーがあります。コンテナ内のすべてのファイルパスは、そのコンテナの環境内だけで決められます。 * Volume mounts can only target a directory in the container, and not an individual file * Volume mounts cannot project files or directories back to the host filesystem * Read-only filesystems are not supported because write access is always required for the Windows registry and SAM database. However, read-only volumes are supported * Volume user-masks and permissions are not available. Because the SAM is not shared between the host & container, there's no mapping between them. All permissions are resolved within the context of the container * ボリュームマウントは、コンテナ内のディレクトリのみを対象にすることができ、個別のファイルは対象にできません * ボリュームマウントは、ファイルまたはディレクトリをホストファイルシステムに投影することはできません * WindowsレジストリとSAMデータベースには常に書き込みアクセスが必要であるため、読み取り専用ファイルシステムはサポートされていません。ただし、読み取り専用ボリュームはサポートされています * ボリュームのユーザーマスクと権限は使用できません。SAMはホストとコンテナ間で共有されないため、それらの間のマッピングはありません。すべての権限はコンテナの環境内で決められます As a result, the following storage functionality is not supported on Windows nodes その結果、次のストレージ機能はWindowsノードではサポートされません。 * Volume subpath mounts. Only the entire volume can be mounted in a Windows container. * Subpath volume mounting for Secrets * Host mount projection * DefaultMode (due to UID/GID dependency) * Read-only root filesystem. Mapped volumes still support readOnly * Block device mapping * Memory as the storage medium * File system features like uui/guid, per-user Linux filesystem permissions * NFS based storage/volume support * Expanding the mounted volume (resizefs) * ボリュームサブパスのマウント。Windowsコンテナにマウントできるのはボリューム全体だけです。 * シークレットのサブパスボリュームのマウント * ホストマウントプロジェクション * DefaultMode(UID/GID依存関係による) * 読み取り専用のルートファイルシステム。マップされたボリュームは引き続き読み取り専用をサポートします * ブロックデバイスマッピング * 記憶媒体としてのメモリ * uui/guid、ユーザーごとのLinuxファイルシステム権限などのファイルシステム機能 * NFSベースのストレージ/ボリュームのサポート * マウントされたボリュームの拡張(resizefs) #### Networking #### ネットワーキング Windows Container Networking differs in some important ways from Linux networking. The [Microsoft documentation for Windows Container Networking](https://docs.microsoft.com/en-us/virtualization/windowscontainers/container-networking/architecture) contains additional details and background. Windowsコンテナネットワーキングは、Linuxネットワーキングとはいくつかの重要な実装方法の違いがあります。[Microsoft documentation for Windows Container Networking](https://docs.microsoft.com/en-us/virtualization/windowscontainers/container-networking/architecture)には、追加の詳細と背景があります。 The Windows host networking networking service and virtual switch implement namespacing and can create virtual NICs as needed for a pod or container. However, many configurations such as DNS, routes, and metrics are stored in the Windows registry database rather than /etc/... files as they are on Linux. The Windows registry for the container is separate from that of the host, so concepts like mapping /etc/resolv.conf from the host into a container don't have the same effect they would on Linux. These must be configured using Windows APIs run in the context of that container. Therefore CNI implementations need to call the HNS instead of relying on file mappings to pass network details into the pod or container. Windowsホストネットワーキングサービスと仮想スイッチはネームスペースを実装して、Podまたはコンテナの必要に応じて仮想NICを作成できます。ただし、DNS、ルート、メトリックなどの多くの構成は、Linuxのような/etc/...ファイルではなく、Windowsレジストリデータベースに保存されます。コンテナのWindowsレジストリはホストのレジストリとは別であるため、ホストからコンテナへの/etc/resolv.confのマッピングなどの概念は、Linuxの場合と同じ効果をもたらしません。これらは、そのコンテナの環境で実行されるWindows APIを使用して構成する必要があります。したがって、CNIの実装は、ファイルマッピングに依存する代わりにHNSを呼び出して、ネットワークの詳細をPodまたはコンテナに渡す必要があります。 The following networking functionality is not supported on Windows nodes 次のネットワーク機能はWindowsノードではサポートされていません * Host networking mode is not available for Windows pods * Local NodePort access from the node itself fails (works for other nodes or external clients) * Accessing service VIPs from nodes will be available with a future release of Windows Server * Overlay networking support in kube-proxy is an alpha release. In addition, it requires [KB4482887](https://support.microsoft.com/en-us/help/4482887/windows-10-update-kb4482887) to be installed on Windows Server 2019 * Local Traffic Policy and DSR mode * Windows containers connected to l2bridge, l2tunnel, or overlay networks do not support communicating over the IPv6 stack. There is outstanding Windows platform work required to enable these network drivers to consume IPv6 addresses and subsequent Kubernetes work in kubelet, kube-proxy, and CNI plugins. * Outbound communication using the ICMP protocol via the win-overlay, win-bridge, and Azure-CNI plugin. Specifically, the Windows data plane ([VFP](https://www.microsoft.com/en-us/research/project/azure-virtual-filtering-platform/)) doesn't support ICMP packet transpositions. This means: * ICMP packets directed to destinations within the same network (e.g. pod to pod communication via ping) work as expected and without any limitations * TCP/UDP packets work as expected and without any limitations * ICMP packets directed to pass through a remote network (e.g. pod to external internet communication via ping) cannot be transposed and thus will not be routed back to their source * Since TCP/UDP packets can still be transposed, one can substitute `ping ` with `curl ` to be able to debug connectivity to the outside world. * ホストネットワーキングモードはWindows Podでは使用できません * ノード自体からのローカルNodePortアクセスは失敗します(他のノードまたは外部クライアントで機能) * ノードからのService VIPへのアクセスは、Windows Serverの将来のリリースで利用可能になる予定です * kube-proxyのオーバーレイネットワーキングサポートはアルファリリースです。さらに、[KB4482887](https://support.microsoft.com/en-us/help/4482887/windows-10-update-kb4482887)がWindows Server 2019にインストールされている必要があります * ローカルトラフィックポリシーとDSRモード * l2bridge、l2tunnel、またはオーバーレイネットワークに接続されたWindowsコンテナは、IPv6スタックを介した通信をサポートしていません。これらのネットワークドライバーがIPv6アドレスを使用できるようにするために必要な機能として、優れたWindowsプラットフォームの機能があり、それに続いて、kubelet、kube-proxy、およびCNIプラグインといったKubernetesの機能があります。 * win-overlay、win-bridge、およびAzure-CNIプラグインを介したICMPプロトコルを使用したアウトバウンド通信。具体的には、Windowsデータプレーン([VFP](https://www.microsoft.com/en-us/research/project/azure-virtual-filtering-platform/))は、ICMPパケットの置き換えをサポートしていません。これの意味は: * 同じネットワーク内の宛先に向けられたICMPパケット(pingを介したPod間通信など)は期待どおりに機能し、制限はありません * TCP/UDPパケットは期待どおりに機能し、制限はありません * リモートネットワーク(Podからping経由の外部インターネット通信など)を通過するように指示されたICMPパケットは置き換えできないため、ソースにルーティングされません。 * TCP/UDPパケットは引き続き置き換えできるため、`ping `を`curl `に置き換えることで、外部への接続をデバッグできます。 These features were added in Kubernetes v1.15: これらの機能はKubernetes v1.15で追加されました。 * `kubectl port-forward` ##### CNI Plugins ##### CNIプラグイン * Windows reference network plugins win-bridge and win-overlay do not currently implement [CNI spec](https://github.com/containernetworking/cni/blob/master/SPEC.md) v0.4.0 due to missing \"CHECK\" implementation. * The Flannel VXLAN CNI has the following limitations on Windows: * Windowsリファレンスネットワークプラグインのwin-bridgeとwin-overlayは、[CNI仕様](https://github.com/containernetworking/cni/blob/master/SPEC.md)v0.4.0において「CHECK」実装がないため、今のところ実装されていません。 * Flannel VXLAN CNIについては、Windowsで次の制限があります。: 1. Node-pod connectivity isn't possible by design. It's only possible for local pods with Flannel [PR 1096](https://github.com/coreos/flannel/pull/1096) 2. We are restricted to using VNI 4096 and UDP port 4789. The VNI limitation is being worked on and will be overcome in a future release (open-source flannel changes). See the official [Flannel VXLAN](https://github.com/coreos/flannel/blob/master/Documentation/backends.md#vxlan) backend docs for more details on these parameters. 1. Node-podの直接間接続は設計上不可能です。Flannel[PR 1096](https://github.com/coreos/flannel/pull/1096)を使用するローカルPodでのみ可能です 2. VNI 4096とUDPポート4789の使用に制限されています。VNIの制限は現在取り組んでおり、将来のリリースで解決される予定です(オープンソースのflannelの変更)。これらのパラメーターの詳細については、公式の[Flannel VXLAN](https://github.com/coreos/flannel/blob/master/Documentation/backends.md#vxlan)バックエンドのドキュメントをご覧ください。 ##### DNS {#dns-limitations} * ClusterFirstWithHostNet is not supported for DNS. Windows treats all names with a '.' as a FQDN and skips PQDN resolution * On Linux, you have a DNS suffix list, which is used when trying to resolve PQDNs. On Windows, we only have 1 DNS suffix, which is the DNS suffix associated with that pod's namespace (mydns.svc.cluster.local for example). Windows can resolve FQDNs and services or names resolvable with just that suffix. For example, a pod spawned in the default namespace, will have the DNS suffix **default.svc.cluster.local**. On a Windows pod, you can resolve both **kubernetes.default.svc.cluster.local** and **kubernetes**, but not the in-betweens, like **kubernetes.default** or **kubernetes.default.svc**. * On Windows, there are multiple DNS resolvers that can be used. As these come with slightly different behaviors, using the `Resolve-DNSName` utility for name query resolutions is recommended. * ClusterFirstWithHostNetは、DNSでサポートされていません。Windowsでは、FQDNとしてすべての名前を「.」で扱い、PQDNでの名前解決はスキップします。 * Linuxでは、PQDNで名前解決しようとするときに使用するDNSサフィックスリストがあります。Windowsでは、1つのDNSサフィックスしかありません。これは、そのPodのNamespaceに関連付けられているDNSサフィックスです(たとえば、mydns.svc.cluster.local)。Windowsでは、そのサフィックスだけで名前解決可能なFQDNおよびServiceまたはNameでの名前解決ができます。たとえば、defaultのNamespaceで生成されたPodには、DNSサフィックス**default.svc.cluster.local**が付けられます。WindowsのPodでは、**kubernetes.default.svc.cluster.local**と**kubernetes**の両方を名前解決できますが、**kubernetes.default**や**kubernetes.default.svc**のような中間での名前解決はできません。 * Windowsでは、複数のDNSリゾルバーを使用できます。これらには少し異なる動作が付属しているため、ネームクエリの解決には`Resolve-DNSName`ユーティリティを使用することをお勧めします。 ##### Security ##### セキュリティ Secrets are written in clear text on the node's volume (as compared to tmpfs/in-memory on linux). This means customers have to do two things Secretはノードのボリュームに平文テキストで書き込まれます(Linuxのtmpfs/in-memoryの比較として)。これはカスタマーが2つのことを行う必要があります 1. Use file ACLs to secure the secrets file location 2. Use volume-level encryption using [BitLocker](https://docs.microsoft.com/en-us/windows/security/information-protection/bitlocker/bitlocker-how-to-deploy-on-windows-server) 1. ファイルACLを使用してSecretファイルの場所を保護する 2. [BitLocker](https://docs.microsoft.com/en-us/windows/security/information-protection/bitlocker/bitlocker-how-to-deploy-on-windows-server)を使って、ボリュームレベルの暗号化を使用する [RunAsUser ](/docs/concepts/policy/pod-security-policy/#users-and-groups)is not currently supported on Windows. The workaround is to create local accounts before packaging the container. The RunAsUsername capability may be added in a future release. [RunAsUser](/docs/concepts/policy/pod-security-policy/#users-and-groups)は、現在Windowsではサポートされていません。回避策は、コンテナをパッケージ化する前にローカルアカウントを作成することです。RunAsUsername機能は、将来のリリースで追加される可能性があります。 Linux specific pod security context privileges such as SELinux, AppArmor, Seccomp, Capabilities (POSIX Capabilities), and others are not supported. SELinux、AppArmor、Seccomp、特性(POSIX機能)のような、Linux固有のPodセキュリティ環境の権限はサポートされていません。 In addition, as mentioned already, privileged containers are not supported on Windows. さらに、既に述べたように特権付きコンテナは、Windowsにおいてサポートされていません。 #### API There are no differences in how most of the Kubernetes APIs work for Windows. The subtleties around what's different come down to differences in the OS and container runtime. In certain situations, some properties on workload APIs such as Pod or Container were designed with an assumption that they are implemented on Linux, failing to run on Windows. ほとんどのKubernetes APIがWindowsでも機能することに違いはありません。そのわずかな違いはOSとコンテナランタイムの違いによるものです。特定の状況では、PodやコンテナなどのワークロードAPIの一部のプロパティが、Linuxで実装されているが、Windowsでは実行できないことを前提に設計されています。 At a high level, these OS concepts are different: 高いレベルで、これらOSのコンセプトに違いがります。: * Identity - Linux uses userID (UID) and groupID (GID) which are represented as integer types. User and group names are not canonical - they are just an alias in `/etc/groups` or `/etc/passwd` back to UID+GID. Windows uses a larger binary security identifier (SID) which is stored in the Windows Security Access Manager (SAM) database. This database is not shared between the host and containers, or between containers. * File permissions - Windows uses an access control list based on SIDs, rather than a bitmask of permissions and UID+GID * File paths - convention on Windows is to use `` instead of `/`. The Go IO libraries typically accept both and just make it work, but when you're setting a path or command line that's interpreted inside a container, `` may be needed. * Signals - Windows interactive apps handle termination differently, and can implement one or more of these: * A UI thread handles well-defined messages including WM_CLOSE * Console apps handle ctrl-c or ctrl-break using a Control Handler * Services register a Service Control Handler function that can accept SERVICE_CONTROL_STOP control codes * ID - Linuxでは、Integer型として表されるuserID(UID)とgroupID(GID)を使用します。ユーザー名とグループ名は正規ではありません - それらは、UID+GIDの背後にある`/etc/groups`または`/etc/passwd`の単なるエイリアスです。Windowsは、Windows Security Access Manager(SAM)データベースに格納されているより大きなバイナリセキュリティ識別子(SID)を使用します。このデータベースは、ホストとコンテナ間、またはコンテナ間で共有されません。 * ファイル権限 - Windowsは、権限とUID+GIDのビットマスクではなく、SIDに基づくアクセス制御リストを使用します * ファイルパス - Windowsの規則では、`/`ではなく``を使用します。Go IOライブラリは通常両方を受け入れ、それを機能させるだけですが、コンテナ内で解釈されるパスまたはコマンドラインを設定する場合、``が必要になる場合があります。 * シグナル - Windowsのインタラクティブなアプリは終了を異なる方法で処理し、次の1つ以上を実装できます。: * UIスレッドは、WM_CLOSEを含む明確に定義されたメッセージを処理します * コンソールアプリは、コントロールハンドラーを使用してctrl-cまたはctrl-breakを処理します * サービスは、SERVICE_CONTROL_STOP制御コードを受け入れることができるサービスコントロールハンドラー関数を登録します。 Exit Codes follow the same convention where 0 is success, nonzero is failure. The specific error codes may differ across Windows and Linux. However, exit codes passed from the Kubernetes components (kubelet, kube-proxy) are unchanged. 終了コードは、0が成功、0以外が失敗の場合と同じ規則に従います。特定のエラーコードは、WindowsとLinuxで異なる場合があります。ただし、Kubernetesのコンポーネント(kubelet、kube-proxy)から渡される終了コードは変更されていません。 ##### V1.Container * V1.Container.ResourceRequirements.limits.cpu and V1.Container.ResourceRequirements.limits.memory - Windows doesn't use hard limits for CPU allocations. Instead, a share system is used. The existing fields based on millicores are scaled into relative shares that are followed by the Windows scheduler. [see: kuberuntime/helpers_windows.go](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kuberuntime/helpers_windows.go), [see: resource controls in Microsoft docs](https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/resource-controls) * Huge pages are not implemented in the Windows container runtime, and are not available. They require [asserting a user privilege](https://docs.microsoft.com/en-us/windows/desktop/Memory/large-page-support) that's not configurable for containers. * V1.Container.ResourceRequirements.requests.cpu and V1.Container.ResourceRequirements.requests.memory - Requests are subtracted from node available resources, so they can be used to avoid overprovisioning a node. However, they cannot be used to guarantee resources in an overprovisioned node. They should be applied to all containers as a best practice if the operator wants to avoid overprovisioning entirely. * V1.Container.SecurityContext.allowPrivilegeEscalation - not possible on Windows, none of the capabilities are hooked up * V1.Container.SecurityContext.Capabilities - POSIX capabilities are not implemented on Windows * V1.Container.SecurityContext.privileged - Windows doesn't support privileged containers * V1.Container.SecurityContext.procMount - Windows doesn't have a /proc filesystem * V1.Container.SecurityContext.readOnlyRootFilesystem - not possible on Windows, write access is required for registry & system processes to run inside the container * V1.Container.SecurityContext.runAsGroup - not possible on Windows, no GID support * V1.Container.SecurityContext.runAsNonRoot - Windows does not have a root user. The closest equivalent is ContainerAdministrator which is an identity that doesn't exist on the node. * V1.Container.SecurityContext.runAsUser - not possible on Windows, no UID support as int. * V1.Container.SecurityContext.seLinuxOptions - not possible on Windows, no SELinux * V1.Container.terminationMessagePath - this has some limitations in that Windows doesn't support mapping single files. The default value is /dev/termination-log, which does work because it does not exist on Windows by default. * V1.Container.ResourceRequirements.limits.cpuおよびV1.Container.ResourceRequirements.limits.memory - Windowsは、CPU割り当てにハード制限を使用しません。代わりに、共有システムが使用されます。ミリコアに基づく既存のフィールドは、Windowsスケジューラーによって追従される相対共有にスケーリングされます。[参照: kuberuntime/helpers_windows.go](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kuberuntime/helpers_windows.go)、[参照: resource controls in Microsoft docs](https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/resource-controls) * Huge Pagesは、Windowsコンテナランタイムには実装されてないので、使用できません。コンテナに対して設定できない[ユーザー特権を主張](https://docs.microsoft.com/en-us/windows/desktop/Memory/large-page-support)する必要があります。 * V1.Container.ResourceRequirements.requests.cpuおよびV1.Container.ResourceRequirements.requests.memory - リクエストはノードの利用可能なリソースから差し引かれるので、ノードのオーバープロビジョニングを回避するために使用できます。ただし、過剰にプロビジョニングされたノードのリソースを保証するために使用することはできません。オペレーターが完全にプロビジョニングし過ぎないようにする場合は、ベストプラクティスとしてこれらをすべてのコンテナに適用する必要があります。 * V1.Container.SecurityContext.allowPrivilegeEscalation - Windowsでは使用できません、接続されている機能はありません * V1.Container.SecurityContext.Capabilities - POSIX機能はWindowsでは実装されていません * V1.Container.SecurityContext.privileged - Windowsでは特権コンテナをサポートしていません * V1.Container.SecurityContext.procMount - Windowsでは/procファイルシステムがありません * V1.Container.SecurityContext.readOnlyRootFilesystem - Windowsでは使用できません、レジストリおよびシステムプロセスがコンテナ内で実行するには、書き込みアクセスが必要です * V1.Container.SecurityContext.runAsGroup - Windowsでは使用できません、GIDのサポートもありません * V1.Container.SecurityContext.runAsNonRoot - Windowsではrootユーザーが存在しません。最も近いものは、ノードに存在しないIDであるContainerAdministratorです。 * V1.Container.SecurityContext.runAsUser - Windowsでは使用できません。intとしてのUIDはサポートされていません。 * V1.Container.SecurityContext.seLinuxOptions - Windowsでは使用できません、SELinuxがありません * V1.Container.terminationMessagePath - これは、Windowsが単一ファイルのマッピングをサポートしないという点でいくつかの制限があります。デフォルト値は/dev/termination-logであり、デフォルトではWindowsに存在しないため動作します。 ##### V1.Pod * V1.Pod.hostIPC, v1.pod.hostpid - host namespace sharing is not possible on Windows * V1.Pod.hostNetwork - There is no Windows OS support to share the host network * V1.Pod.dnsPolicy - ClusterFirstWithHostNet - is not supported because Host Networking is not supported on Windows. * V1.Pod.podSecurityContext - see V1.PodSecurityContext below * V1.Pod.shareProcessNamespace - this is a beta feature, and depends on Linux namespaces which are not implemented on Windows. Windows cannot share process namespaces or the container's root filesystem. Only the network can be shared. * V1.Pod.terminationGracePeriodSeconds - this is not fully implemented in Docker on Windows, see: [reference](https://github.com/moby/moby/issues/25982). The behavior today is that the ENTRYPOINT process is sent CTRL_SHUTDOWN_EVENT, then Windows waits 5 seconds by default, and finally shuts down all processes using the normal Windows shutdown behavior. The 5 second default is actually in the Windows registry [inside the container](https://github.com/moby/moby/issues/25982#issuecomment-426441183), so it can be overridden when the container is built. * V1.Pod.volumeDevices - this is a beta feature, and is not implemented on Windows. Windows cannot attach raw block devices to pods. * V1.Pod.volumes - EmptyDir, Secret, ConfigMap, HostPath - all work and have tests in TestGrid * V1.emptyDirVolumeSource - the Node default medium is disk on Windows. Memory is not supported, as Windows does not have a built-in RAM disk. * V1.VolumeMount.mountPropagation - mount propagation is not supported on Windows. * V1.Pod.hostIPC、v1.pod.hostpid - Windowsではホストのネームスペースを共有することはできません * V1.Pod.hostNetwork - ホストのネットワークを共有するためのWindows OSサポートはありません * V1.Pod.dnsPolicy - ClusterFirstWithHostNet - Windowsではホストネットワーキングがサポートされていないため、サポートされていません。 * V1.Pod.podSecurityContext - 以下のV1.PodSecurityContextを参照 * V1.Pod.shareProcessNamespace - これはベータ版の機能であり、Windowsに実装されていないLinuxのNamespace機能に依存しています。Windowsでは、プロセスのネームスペースまたはコンテナのルートファイルシステムを共有できません。共有できるのはネットワークだけです。 * V1.Pod.terminationGracePeriodSeconds - これはWindowsのDockerに完全には実装されていません。[リファレンス](https://github.com/moby/moby/issues/25982)を参照してください。今日の動作では、ENTRYPOINTプロセスにCTRL_SHUTDOWN_EVENTが送信され、Windowsではデフォルトで5秒待機し、最後に通常のWindowsシャットダウン動作を使用してすべてのプロセスをシャットダウンします。5秒のデフォルトは、実際にはWindowsレジストリー[コンテナ内](https://github.com/moby/moby/issues/25982#issuecomment-426441183)にあるため、コンテナ作成時にオーバーライドできます。 * V1.Pod.volumeDevices - これはベータ機能であり、Windowsには実装されていません。Windowsでは、rawブロックデバイスをPodに接続できません。 * V1.Pod.volumes-EmptyDir、Secret、ConfigMap、HostPath - すべて動作し、TestGridにテストがあります * V1.emptyDirVolumeSource - ノードのデフォルトのメディアはWindowsのディスクです。Windowsでは、RAMディスクが組み込まれていないため、メモリはサポートされていません。 * V1.VolumeMount.mountPropagation - mount propagationは、Windowsではサポートされていません。 ##### V1.PodSecurityContext None of the PodSecurityContext fields work on Windows. They're listed here for reference. Windowsでは、PodSecurityContextフィールドはどれも機能しません。これらは参照用にここにリストされています。 * V1.PodSecurityContext.SELinuxOptions - SELinux is not available on Windows * V1.PodSecurityContext.RunAsUser - provides a UID, not available on Windows * V1.PodSecurityContext.RunAsGroup - provides a GID, not available on Windows * V1.PodSecurityContext.RunAsNonRoot - Windows does not have a root user. The closest equivalent is ContainerAdministrator which is an identity that doesn't exist on the node. * V1.PodSecurityContext.SupplementalGroups - provides GID, not available on Windows * V1.PodSecurityContext.Sysctls - these are part of the Linux sysctl interface. There's no equivalent on Windows. * V1.PodSecurityContext.SELinuxOptions - SELinuxは、Windowsでは使用できません * V1.PodSecurityContext.RunAsUser - UIDを提供しますが、Windowsでは使用できません * V1.PodSecurityContext.RunAsGroup - GIDを提供しますが、Windowsでは使用できません * V1.PodSecurityContext.RunAsNonRoot - Windowsにはrootユーザーがありません。最も近いものは、ノードに存在しないIDであるContainerAdministratorです。 * V1.PodSecurityContext.SupplementalGroups - GIDを提供しますが、Windowsでは使用できません * V1.PodSecurityContext.Sysctls - これらはLinuxのsysctlインターフェースの一部です。Windowsには同等のものはありません。 ## Getting Help and Troubleshooting {#troubleshooting} ## ヘルプとトラブルシューティングを学ぶ {#troubleshooting} Your main source of help for troubleshooting your Kubernetes cluster should start with this [section](/docs/tasks/debug-application-cluster/troubleshooting/). Some additional, Windows-specific troubleshooting help is included in this section. Logs are an important element of troubleshooting issues in Kubernetes. Make sure to include them any time you seek troubleshooting assistance from other contributors. Follow the instructions in the SIG-Windows [contributing guide on gathering logs](https://github.com/kubernetes/community/blob/master/sig-windows/CONTRIBUTING.md#gathering-logs). Kubernetesクラスターのトラブルシューティングの主なヘルプソースは、この[セクション](/docs/tasks/debug-application-cluster/troubleshooting/)から始める必要があります。このセクションには、いくつか追加的な、Windows固有のトラブルシューティングヘルプが含まれています。ログは、Kubernetesにおけるトラブルシューティング問題の重要な要素です。他のコントリビューターからトラブルシューティングの支援を求めるときは、必ずそれらを含めてください。SIG-Windows[ログ収集に関するコントリビュートガイド](https://github.com/kubernetes/community/blob/master/sig-windows/CONTRIBUTING.md#gathering-logs)の指示に従ってください。 1. How do I know start.ps1 completed successfully? 1. start.ps1が正常に完了したことをどのように確認できますか? You should see kubelet, kube-proxy, and (if you chose Flannel as your networking solution) flanneld host-agent processes running on your node, with running logs being displayed in separate PowerShell windows. In addition to this, your Windows node should be listed as \"Ready\" in your Kubernetes cluster. ノード上でkubelet、kube-proxy、および(ネットワーキングソリューションとしてFlannelを選択した場合)flanneldホストエージェントプロセスが実行され、実行ログが個別のPowerShellウィンドウに表示されます。これに加えて、WindowsノードがKubernetesクラスターで「Ready」として表示されているはずです。 1. Can I configure the Kubernetes node processes to run in the background as services? 1. Kubernetesノードのプロセスをサービスとしてバックグラウンドで実行するように構成できますか? Kubelet and kube-proxy are already configured to run as native Windows Services, offering resiliency by re-starting the services automatically in the event of failure (for example a process crash). You have two options for configuring these node components as services. Kubeletとkube-proxyは、ネイティブのWindowsサービスとして実行するように既に構成されています、障害(例えば、プロセスのクラッシュ)が発生した場合にサービスを自動的に再起動することにより、復元性を提供します。これらのノードコンポーネントをサービスとして構成するには、2つのオプションがあります。 1. As native Windows Services 1. ネイティブWindowsサービスとして Kubelet & kube-proxy can be run as native Windows Services using `sc.exe`. Kubeletとkube-proxyは、`sc.exe`を使用してネイティブのWindowsサービスとして実行できます。 ```powershell # Create the services for kubelet and kube-proxy in two separate commands # 2つの個別のコマンドでkubeletおよびkube-proxyのサービスを作成する sc.exe create binPath= \" --service \" # Please note that if the arguments contain spaces, they must be escaped. # 引数にスペースが含まれている場合は、エスケープする必要があることに注意してください。 sc.exe create kubelet binPath= \"C:kubelet.exe --service --hostname-override 'minion' \" # Start the services # サービスを開始する Start-Service kubelet Start-Service kube-proxy # Stop the service # サービスを停止する Stop-Service kubelet (-Force) Stop-Service kube-proxy (-Force) # Query the service status # サービスの状態を問い合わせる Get-Service kubelet Get-Service kube-proxy ``` 1. Using nssm.exe 1. nssm.exeの使用 You can also always use alternative service managers like [nssm.exe](https://nssm.cc/) to run these processes (flanneld, kubelet & kube-proxy) in the background for you. You can use this [sample script](https://github.com/Microsoft/SDN/tree/master/Kubernetes/flannel/register-svc.ps1), leveraging nssm.exe to register kubelet, kube-proxy, and flanneld.exe to run as Windows services in the background. また、[nssm.exe](https://nssm.cc/)などの代替サービスマネージャーを使用して、これらのプロセス(flanneld、kubelet、kube-proxy)をバックグラウンドで実行することもできます。この[サンプルスクリプト](https://github.com/Microsoft/SDN/tree/master/Kubernetes/flannel/register-svc.ps1)を使用すると、nssm.exeを利用してkubelet、kube-proxy、flanneld.exeを登録し、Windowsサービスとしてバックグラウンドで実行できます。 ```powershell register-svc.ps1 -NetworkMode -ManagementIP -ClusterCIDR -KubeDnsServiceIP -LogDir # NetworkMode = The network mode l2bridge (flannel host-gw, also the default value) or overlay (flannel vxlan) chosen as a network solution # ManagementIP = The IP address assigned to the Windows node. You can use ipconfig to find this # ClusterCIDR = The cluster subnet range. (Default value 10.244.0.0/16) # KubeDnsServiceIP = The Kubernetes DNS service IP (Default value 10.96.0.10) # LogDir = The directory where kubelet and kube-proxy logs are redirected into their respective output files (Default value C:k) # NetworkMode = ネットワークソリューションとして選択されたネットワークモードl2bridge(flannel host-gw、これもデフォルト値)またはoverlay(flannel vxlan) # ManagementIP = Windowsノードに割り当てられたIPアドレス。 ipconfigを使用してこれを見つけることができます # ClusterCIDR = クラスターのサブネット範囲。(デフォルト値 10.244.0.0/16) # KubeDnsServiceIP = Kubernetes DNSサービスIP(デフォルト値 10.96.0.10) # LogDir = kubeletおよびkube-proxyログがそれぞれの出力ファイルにリダイレクトされるディレクトリ(デフォルト値 C:k) ``` If the above referenced script is not suitable, you can manually configure nssm.exe using the following examples. 上記のスクリプトが適切でない場合は、次の例を使用してnssm.exeを手動で構成できます。 ```powershell # Register flanneld.exe # flanneld.exeを登録する nssm install flanneld C:flannelflanneld.exe nssm set flanneld AppParameters --kubeconfig-file=c:kconfig --iface= --ip-masq=1 --kube-subnet-mgr=1 nssm set flanneld AppEnvironmentExtra NODE_NAME= nssm set flanneld AppDirectory C:flannel nssm start flanneld # Register kubelet.exe # Microsoft releases the pause infrastructure container at mcr.microsoft.com/k8s/core/pause:1.2.0 # For more info search for \"pause\" in the \"Guide for adding Windows Nodes in Kubernetes\" # kubelet.exeを登録 # マイクロソフトは、mcr.microsoft.com/k8s/core/pause:1.2.0としてポーズインフラストラクチャコンテナをリリース # 詳細については、「KubernetesにWindowsノードを追加するためのガイド」で「pause」を検索してください nssm install kubelet C:kkubelet.exe nssm set kubelet AppParameters --hostname-override= --v=6 --pod-infra-container-image=mcr.microsoft.com/k8s/core/pause:1.2.0 --resolv-conf=\"\" --allow-privileged=true --enable-debugging-handlers --cluster-dns= --cluster-domain=cluster.local --kubeconfig=c:kconfig --hairpin-mode=promiscuous-bridge --image-pull-progress-deadline=20m --cgroups-per-qos=false --log-dir= --logtostderr=false --enforce-node-allocatable=\"\" --network-plugin=cni --cni-bin-dir=c:kcni --cni-conf-dir=c:kcniconfig nssm set kubelet AppDirectory C:k nssm start kubelet # Register kube-proxy.exe (l2bridge / host-gw) # kube-proxy.exeを登録する (l2bridge / host-gw) nssm install kube-proxy C:kkube-proxy.exe nssm set kube-proxy AppDirectory c:k nssm set kube-proxy AppParameters --v=4 --proxy-mode=kernelspace --hostname-override=--kubeconfig=c:kconfig --enable-dsr=false --log-dir= --logtostderr=false"} {"_id":"q-en-website-1a5754185e814786a09d4e42a468a5df3e68e90bc04cef1ce5cc4359f9907c09","text":" --- title: Pod 拓扑分布约束 content_type: concept weight: 40 --- 你可以使用 **拓扑分布约束(Topology Spread Constraints)** 来控制 {{< glossary_tooltip text=\"Pod\" term_id=\"Pod\" >}} 在集群内故障域之间的分布, 例如区域(Region)、可用区(Zone)、节点和其他用户自定义拓扑域。 这样做有助于实现高可用并提升资源利用率。 你可以将[集群级约束](#cluster-level-default-constraints)设为默认值,或为个别工作负载配置拓扑分布约束。 ## 动机 {#motivation} 假设你有一个最多包含二十个节点的集群,你想要运行一个自动扩缩的 {{< glossary_tooltip text=\"工作负载\" term_id=\"workload\" >}},请问要使用多少个副本? 答案可能是最少 2 个 Pod,最多 15 个 Pod。 当只有 2 个 Pod 时,你倾向于这 2 个 Pod 不要同时在同一个节点上运行: 你所遭遇的风险是如果放在同一个节点上且单节点出现故障,可能会让你的工作负载下线。 除了这个基本的用法之外,还有一些高级的使用案例,能够让你的工作负载受益于高可用性并提高集群利用率。 随着你的工作负载扩容,运行的 Pod 变多,将需要考虑另一个重要问题。 假设你有 3 个节点,每个节点运行 5 个 Pod。这些节点有足够的容量能够运行许多副本; 但与这个工作负载互动的客户端分散在三个不同的数据中心(或基础设施可用区)。 现在你可能不太关注单节点故障问题,但你会注意到延迟高于自己的预期, 在不同的可用区之间发送网络流量会产生一些网络成本。 你决定在正常运营时倾向于将类似数量的副本[调度](/zh-cn/docs/concepts/scheduling-eviction/) 到每个基础设施可用区,且你想要该集群在遇到问题时能够自愈。 Pod 拓扑分布约束使你能够以声明的方式进行配置。 ## `topologySpreadConstraints` 字段 Pod API 包括一个 `spec.topologySpreadConstraints` 字段。这里有一个示例: ```yaml --- apiVersion: v1 kind: Pod metadata: name: example-pod spec: # 配置一个拓扑分布约束 topologySpreadConstraints: - maxSkew: minDomains: # 可选;自从 v1.24 开始成为 Alpha topologyKey: whenUnsatisfiable: labelSelector: ### 其他 Pod 字段置于此处 ``` 你可以运行 `kubectl explain Pod.spec.topologySpreadConstraints` 阅读有关此字段的更多信息。 ### 分布约束定义 你可以定义一个或多个 `topologySpreadConstraints` 条目以指导 kube-scheduler 如何将每个新来的 Pod 与跨集群的现有 Pod 相关联。这些字段包括: - **maxSkew** 描述这些 Pod 可能被均匀分布的程度。你必须指定此字段且该数值必须大于零。 其语义将随着 `whenUnsatisfiable` 的值发生变化: - 如果你选择 `whenUnsatisfiable: DoNotSchedule`,则 `maxSkew` 定义目标拓扑中匹配 Pod 的数量与 **全局最小值**(与拓扑域中标签选择算符匹配的最小 Pod 数量)之间的最大允许差值。 例如,如果你有 3 个可用区,分别有 2、4 和 5 个匹配的 Pod,则全局最小值为 2, 而 `maxSkew` 相对于该数字进行比较。 - 如果你选择 `whenUnsatisfiable: ScheduleAnyway`,则该调度器会更为偏向能够降低偏差值的拓扑域。 - **minDomains** 表示符合条件的域的最小数量。此字段是可选的。域是拓扑的一个特定实例。 符合条件的域是其节点与节点选择器匹配的域。 {{< note >}} `minDomains` 字段是 1.24 中添加的一个 Alpha 字段。 你必须启用 `MinDomainsInPodToplogySpread` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/),才能使用该字段。 {{< /note >}} - 指定的 `minDomains` 值必须大于 0。你可以结合 `whenUnsatisfiable: DoNotSchedule` 仅指定 `minDomains`。 - 当符合条件的、拓扑键匹配的域的数量小于 `minDomains` 时,拓扑分布将“全局最小值”(global minimum)设为 0, 然后进行 `skew` 计算。“全局最小值” 是一个符合条件的域中匹配 Pod 的最小数量, 如果符合条件的域的数量小于 `minDomains`,则全局最小值为零。 - 当符合条件的拓扑键匹配域的个数等于或大于 `minDomains` 时,该值对调度没有影响。 - 如果你未指定 `minDomains`,则约束行为类似于 `minDomains` 等于 1。 - **topologyKey** 是[节点标签](#node-labels)的键。如果两个节点使用此键标记并且具有相同的标签值, 则调度器会将这两个节点视为处于同一拓扑域中。该调度器尝试在每个拓扑域中放置数量均衡的 Pod。 - **whenUnsatisfiable** 指示如果 Pod 不满足分布约束时如何处理: - `DoNotSchedule`(默认)告诉调度器不要调度。 - `ScheduleAnyway` 告诉调度器仍然继续调度,只是根据如何能将偏差最小化来对节点进行排序。 - **labelSelector** 用于查找匹配的 Pod。匹配此标签的 Pod 将被统计,以确定相应拓扑域中 Pod 的数量。 有关详细信息,请参考[标签选择算符](/zh-cn/docs/concepts/overview/working-with-objects/labels/#label-selectors)。 当 Pod 定义了不止一个 `topologySpreadConstraint`,这些约束之间是逻辑与的关系。 kube-scheduler 会为新的 Pod 寻找一个能够满足所有约束的节点。 ### 节点标签 {#node-labels} 拓扑分布约束依赖于节点标签来标识每个{{< glossary_tooltip text=\"节点\" term_id=\"node\" >}}所在的拓扑域。例如,某节点可能具有标签: ```yaml region: us-east-1 zone: us-east-1a ``` {{< note >}} 为了简便,此示例未使用[众所周知](/zh-cn/docs/reference/labels-annotations-taints/)的标签键 `topology.kubernetes.io/zone` 和 `topology.kubernetes.io/region`。 但是,建议使用那些已注册的标签键,而不是此处使用的私有(不合格)标签键 `region` 和 `zone`。 你无法对不同上下文之间的私有标签键的含义做出可靠的假设。 {{< /note >}} 假设你有一个 4 节点的集群且带有以下标签: ``` NAME STATUS ROLES AGE VERSION LABELS node1 Ready 4m26s v1.16.0 node=node1,zone=zoneA node2 Ready 3m58s v1.16.0 node=node2,zone=zoneA node3 Ready 3m17s v1.16.0 node=node3,zone=zoneB node4 Ready 2m43s v1.16.0 node=node4,zone=zoneB ``` 那么,从逻辑上看集群如下: {{}} graph TB subgraph \"zoneB\" n3(Node3) n4(Node4) end subgraph \"zoneA\" n1(Node1) n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4 k8s; class zoneA,zoneB cluster; {{< /mermaid >}} ## 一致性 {#Consistency} 你应该为一个组中的所有 Pod 设置相同的 Pod 拓扑分布约束。 通常,如果你正使用一个工作负载控制器,例如 Deployment,则 Pod 模板会你你解决这个问题。 如果你混合不同的分布约束,则 Kubernetes 会遵循该字段的 API 定义; 但是,该行为可能更令人困惑,并且故障排除也没那么简单。 你需要一种机制来确保拓扑域(例如云提供商区域)中的所有节点具有一致的标签。 为了避免你需要手动为节点打标签,大多数集群会自动填充知名的标签, 例如 `topology.kubernetes.io/hostname`。检查你的集群是否支持此功能。 ## 拓扑分布约束示例 {#topology-spread-constraint-examples} ### 示例:一个拓扑分布约束 {#example-one-topologyspreadconstraint} 假设你拥有一个 4 节点集群,其中标记为 `foo: bar` 的 3 个 Pod 分别位于 node1、node2 和 node3 中: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class zoneA,zoneB cluster; {{< /mermaid >}} 如果你希望新来的 Pod 均匀分布在现有的可用区域,则可以按如下设置其清单: {{< codenew file=\"pods/topology-spread-constraints/one-constraint.yaml\" >}} 从此清单看,`topologyKey: zone` 意味着均匀分布将只应用于存在标签键值对为 `zone: ` 的节点 (没有 `zone` 标签的节点将被跳过)。如果调度器找不到一种方式来满足此约束, 则 `whenUnsatisfiable: DoNotSchedule` 字段告诉该调度器将新来的 Pod 保持在 pending 状态。 如果该调度器将这个新来的 Pod 放到可用区 `A`,则 Pod 的分布将成为 `[3, 1]`。 这意味着实际偏差是 2(计算公式为 `3 - 1`),这违反了 `maxSkew: 1` 的约定。 为了满足这个示例的约束和上下文,新来的 Pod 只能放到可用区 `B` 中的一个节点上: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) p4(mypod) --> n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} 或者 {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) p4(mypod) --> n3 n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} 你可以调整 Pod 规约以满足各种要求: - 将 `maxSkew` 更改为更大的值,例如 `2`,这样新来的 Pod 也可以放在可用区 `A` 中。 - 将 `topologyKey` 更改为 `node`,以便将 Pod 均匀分布在节点上而不是可用区中。 在上面的例子中,如果 `maxSkew` 保持为 `1`,则新来的 Pod 只能放到 `node4` 节点上。 - 将 `whenUnsatisfiable: DoNotSchedule` 更改为 `whenUnsatisfiable: ScheduleAnyway`, 以确保新来的 Pod 始终可以被调度(假设满足其他的调度 API)。但是,最好将其放置在匹配 Pod 数量较少的拓扑域中。 请注意,这一优先判定会与其他内部调度优先级(如资源使用率等)排序准则一起进行标准化。 ### 示例:多个拓扑分布约束 {#example-multiple-topologyspreadconstraints} 下面的例子建立在前面例子的基础上。假设你拥有一个 4 节点集群, 其中 3 个标记为 `foo: bar` 的 Pod 分别位于 node1、node2 和 node3 上: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} 可以组合使用 2 个拓扑分布约束来控制 Pod 在节点和可用区两个维度上的分布: {{< codenew file=\"pods/topology-spread-constraints/two-constraints.yaml\" >}} 在这种情况下,为了匹配第一个约束,新的 Pod 只能放置在可用区 `B` 中; 而在第二个约束中,新来的 Pod 只能调度到节点 `node4` 上。 该调度器仅考虑满足所有已定义约束的选项,因此唯一可行的选择是放置在节点 `node4` 上。 ### 示例:有冲突的拓扑分布约束 {#example-conflicting-topologyspreadconstraints} 多个约束可能导致冲突。假设有一个跨 2 个可用区的 3 节点集群: {{}} graph BT subgraph \"zoneB\" p4(Pod) --> n3(Node3) p5(Pod) --> n3 end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n1 p3(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3,p4,p5 k8s; class zoneA,zoneB cluster; {{< /mermaid >}} 如果你将 [`two-constraints.yaml`](https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/topology-spread-constraints/two-constraints.yaml) (来自上一个示例的清单)应用到**这个**集群,你将看到 Pod `mypod` 保持在 `Pending` 状态。 出现这种情况的原因为:为了满足第一个约束,Pod `mypod` 只能放置在可用区 `B` 中; 而在第二个约束中,Pod `mypod` 只能调度到节点 `node2` 上。 两个约束的交集将返回一个空集,且调度器无法放置该 Pod。 为了应对这种情形,你可以提高 `maxSkew` 的值或修改其中一个约束才能使用 `whenUnsatisfiable: ScheduleAnyway`。 根据实际情形,例如若你在故障排查时发现某个漏洞修复工作毫无进展,你还可能决定手动删除一个现有的 Pod。 #### 与节点亲和性和节点选择算符的相互作用 {#interaction-with-node-affinity-and-node-selectors} 如果 Pod 定义了 `spec.nodeSelector` 或 `spec.affinity.nodeAffinity`, 调度器将在偏差计算中跳过不匹配的节点。 ### 示例:带节点亲和性的拓扑分布约束 {#example-topologyspreadconstraints-with-nodeaffinity} 假设你有一个跨可用区 A 到 C 的 5 节点集群: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} {{}} graph BT subgraph \"zoneC\" n5(Node5) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n5 k8s; class zoneC cluster; {{< /mermaid >}} 而且你知道可用区 `C` 必须被排除在外。在这种情况下,可以按如下方式编写清单, 以便将 Pod `mypod` 放置在可用区 `B` 上,而不是可用区 `C` 上。 同样,Kubernetes 也会一样处理 `spec.nodeSelector`。 {{< codenew file=\"pods/topology-spread-constraints/one-constraint-with-nodeaffinity.yaml\" >}} ## 隐式约定 {#implicit-conventions} 这里有一些值得注意的隐式约定: - 只有与新来的 Pod 具有相同命名空间的 Pod 才能作为匹配候选者。 - 调度器会忽略没有任何 `topologySpreadConstraints[*].topologyKey` 的节点。这意味着: 1. 位于这些节点上的 Pod 不影响 `maxSkew` 计算,在上面的例子中,假设节点 `node1` 没有标签 \"zone\", 则 2 个 Pod 将被忽略,因此新来的 Pod 将被调度到可用区 `A` 中。 2. 新的 Pod 没有机会被调度到这类节点上。在上面的例子中, 假设节点 `node5` 带有 **拼写错误的** 标签 `zone-typo: zoneC`(且没有设置 `zone` 标签)。 节点 `node5` 接入集群之后,该节点将被忽略且针对该工作负载的 Pod 不会被调度到那里。 - 注意,如果新 Pod 的 `topologySpreadConstraints[*].labelSelector` 与自身的标签不匹配,将会发生什么。 在上面的例子中,如果移除新 Pod 的标签,则 Pod 仍然可以放置到可用区 `B` 中的节点上,因为这些约束仍然满足。 然而,在放置之后,集群的不平衡程度保持不变。可用区 `A` 仍然有 2 个 Pod 带有标签 `foo: bar`, 而可用区 `B` 有 1 个 Pod 带有标签 `foo: bar`。如果这不是你所期望的, 更新工作负载的 `topologySpreadConstraints[*].labelSelector` 以匹配 Pod 模板中的标签。 ## 集群级别的默认约束 {#cluster-level-default-constraints} 为集群设置默认的拓扑分布约束也是可能的。默认拓扑分布约束在且仅在以下条件满足时才会被应用到 Pod 上: - Pod 没有在其 `.spec.topologySpreadConstraints` 中定义任何约束。 - Pod 隶属于某个 Service、ReplicaSet、StatefulSet 或 ReplicationController。 默认约束可以设置为[调度方案](/zh-cn/docs/reference/scheduling/config/#profiles)中 `PodTopologySpread` 插件参数的一部分。约束的设置采用[如前所述的 API](#api), 只是 `labelSelector` 必须为空。 选择算符是根据 Pod 所属的 Service、ReplicaSet、StatefulSet 或 ReplicationController 来设置的。 配置的示例可能看起来像下面这个样子: ```yaml apiVersion: kubescheduler.config.k8s.io/v1beta3 kind: KubeSchedulerConfiguration profiles: - schedulerName: default-scheduler pluginConfig: - name: PodTopologySpread args: defaultConstraints: - maxSkew: 1 topologyKey: topology.kubernetes.io/zone whenUnsatisfiable: ScheduleAnyway defaultingType: List ``` {{< note >}} 默认配置下,[`SelectorSpread` 插件](/zh-cn/docs/reference/scheduling/config/#scheduling-plugins)是被禁用的。 Kubernetes 项目建议使用 `PodTopologySpread` 以执行类似行为。 {{< /note >}} ### 内置默认约束 {#internal-default-constraints} {{< feature-state for_k8s_version=\"v1.24\" state=\"stable\" >}} 如果你没有为 Pod 拓扑分布配置任何集群级别的默认约束, kube-scheduler 的行为就像你指定了以下默认拓扑约束一样: ```yaml defaultConstraints: - maxSkew: 3 topologyKey: \"kubernetes.io/hostname\" whenUnsatisfiable: ScheduleAnyway - maxSkew: 5 topologyKey: \"topology.kubernetes.io/zone\" whenUnsatisfiable: ScheduleAnyway ``` 此外,原来用于提供等同行为的 `SelectorSpread` 插件默认被禁用。 {{< note >}} 对于分布约束中所指定的拓扑键而言,`PodTopologySpread` 插件不会为不包含这些拓扑键的节点评分。 这可能导致在使用默认拓扑约束时,其行为与原来的 `SelectorSpread` 插件的默认行为不同。 如果你的节点不会 **同时** 设置 `kubernetes.io/hostname` 和 `topology.kubernetes.io/zone` 标签, 你应该定义自己的约束而不是使用 Kubernetes 的默认约束。 {{< /note >}} 如果你不想为集群使用默认的 Pod 分布约束,你可以通过设置 `defaultingType` 参数为 `List`, 并将 `PodTopologySpread` 插件配置中的 `defaultConstraints` 参数置空来禁用默认 Pod 分布约束: ```yaml apiVersion: kubescheduler.config.k8s.io/v1beta3 kind: KubeSchedulerConfiguration profiles: - schedulerName: default-scheduler pluginConfig: - name: PodTopologySpread args: defaultConstraints: [] defaultingType: List ``` ## 比较 podAffinity 和 podAntiAffinity {#comparison-with-podaffinity-podantiaffinity} 在 Kubernetes 中,Pod 间亲和性和反亲和性控制 Pod 彼此的调度方式(更密集或更分散)。 对于 `podAffinity`:吸引 Pod;你可以尝试将任意数量的 Pod 集中到符合条件的拓扑域中。 对于 `podAntiAffinity`:驱逐 Pod。如果将此设为 `requiredDuringSchedulingIgnoredDuringExecution` 模式, 则只有单个 Pod 可以调度到单个拓扑域;如果你选择 `preferredDuringSchedulingIgnoredDuringExecution`, 则你将丢失强制执行此约束的能力。 要实现更细粒度的控制,你可以设置拓扑分布约束来将 Pod 分布到不同的拓扑域下,从而实现高可用性或节省成本。 这也有助于工作负载的滚动更新和平稳地扩展副本规模。 有关详细信息,请参阅有关 Pod 拓扑分布约束的增强倡议的 [动机](https://github.com/kubernetes/enhancements/tree/master/keps/sig-scheduling/895-pod-topology-spread#motivation)一节。 ## 已知局限性 {#known-limitations} - 当 Pod 被移除时,无法保证约束仍被满足。例如,缩减某 Deployment 的规模时,Pod 的分布可能不再均衡。 你可以使用 [Descheduler](https://github.com/kubernetes-sigs/descheduler) 来重新实现 Pod 分布的均衡。 - 具有污点的节点上匹配的 Pod 也会被统计。 参考 [Issue 80921](https://github.com/kubernetes/kubernetes/issues/80921)。 - 该调度器不会预先知道集群拥有的所有可用区和其他拓扑域。 拓扑域由集群中存在的节点确定。在自动扩缩的集群中,如果一个节点池(或节点组)的节点数量缩减为零, 而用户正期望其扩容时,可能会导致调度出现问题。 因为在这种情况下,调度器不会考虑这些拓扑域,因为其中至少有一个节点。 你可以通过使用感知 Pod 拓扑分布约束并感知整个拓扑域集的集群自动扩缩工具来解决此问题。 ## {{% heading \"whatsnext\" %}} - 博客:[PodTopologySpread 介绍](/blog/2020/05/introducing-podtopologyspread/)详细解释了 `maxSkew`, 并给出了一些进阶的使用示例。 - 阅读针对 Pod 的 API 参考的 [调度](/zh-cn/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling)一节。 "} {"_id":"q-en-website-1b20ff615eb779ee53f3bd556c29cdaad9359f34552620f24754c2469d6e1780","text":" --- title: クラウドプロバイダー content_type: concept weight: 30 --- このページでは、特定のクラウドプロバイダーで実行されているKubernetesを管理する方法について説明します。 ### kubeadm [kubeadm](/ja/docs/reference/setup-tools/kubeadm/kubeadm/)は、Kubernetesクラスターを作成する選択肢として人気があります。 kubeadmには、クラウドプロバイダーの設定情報を指定する設定オプションがあります。 例えば、典型的なインツリークラウドプロバイダーは、以下のようにkubeadmを使用して設定することができます。 ```yaml apiVersion: kubeadm.k8s.io/v1beta2 kind: InitConfiguration nodeRegistration: kubeletExtraArgs: cloud-provider: \"openstack\" cloud-config: \"/etc/kubernetes/cloud.conf\" --- apiVersion: kubeadm.k8s.io/v1beta2 kind: ClusterConfiguration kubernetesVersion: v1.13.0 apiServer: extraArgs: cloud-provider: \"openstack\" cloud-config: \"/etc/kubernetes/cloud.conf\" extraVolumes: - name: cloud hostPath: \"/etc/kubernetes/cloud.conf\" mountPath: \"/etc/kubernetes/cloud.conf\" controllerManager: extraArgs: cloud-provider: \"openstack\" cloud-config: \"/etc/kubernetes/cloud.conf\" extraVolumes: - name: cloud hostPath: \"/etc/kubernetes/cloud.conf\" mountPath: \"/etc/kubernetes/cloud.conf\" ``` 典型的なインツリークラウドプロバイダーは、通常、[kube-apiserver](/ja/docs/reference/command-line-tools-reference/kube-apiserver/)および[kube-controller-manager](ja//docs/reference/command-line-tools-reference/kube-controller-manager/)、[kubelet](/ja/docs/reference/command-line-tools-reference/kubelet/)のコマンドラインで指定される`--cloud-provider`と`--cloud-config`の両方が必要です。 プロバイダーごとに`--cloud-config`で指定されるファイルの内容についても、以下に記載します。 すべての外部クラウドプロバイダーについては、以下の見出しに列挙されている個々のリポジトリーの案内に従ってください。または[すべてのリポジトリーのリスト](https://github.com/kubernetes?q=cloud-provider-&type=&language=)もご覧ください。 ## AWS ここでは、Amazon Web ServicesでKubernetesを実行する際に使用できるすべての設定について説明します。 この外部クラウドプロバイダーを利用したい場合、[kubernetes/cloud-provider-aws](https://github.com/kubernetes/cloud-provider-aws#readme)リポジトリーを参照してください。 ### ノード名 AWSクラウドプロバイダーは、AWSインスタンスのプライベートDNS名をKubernetesのNodeオブジェクトの名前として使用します。 ### ロードバランサー 以下のようにアノテーションを設定することで、[外部ロードバランサー](/ja/docs/tasks/access-application-cluster/create-external-load-balancer/)をAWS上で特定の機能を利用するように構成できます。 ```yaml apiVersion: v1 kind: Service metadata: name: example namespace: kube-system labels: run: example annotations: service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:xx-xxxx-x:xxxxxxxxx:xxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx #replace this value service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http spec: type: LoadBalancer ports: - port: 443 targetPort: 5556 protocol: TCP selector: app: example ``` AWSのロードバランサーサービスには、_アノテーション_ を使ってさまざまな設定を適用することができます。以下では、AWS ELBでサポートされているアノテーションについて説明します。 * `service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval`: アクセスログの送信間隔を指定するために使用します。 * `service.beta.kubernetes.io/aws-load-balancer-access-log-enabled`: アクセスログを有効または無効にするためにサービスで使用します。 * `service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name`: アクセスログ用のs3バケット名を指定するために使用します。 * `service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix`: アクセスログ用のs3バケットのプレフィックスを指定するために使用します。 * `service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags`: ELBに追加タグとして記録されるキーとバリューのペアのコンマ区切りリストとして指定するためにサービスで使用します。例えば、`\"Key1=Val1,Key2=Val2,KeyNoVal1=,KeyNoVal2\"`のように指定できます。 * `service.beta.kubernetes.io/aws-load-balancer-backend-protocol`: リスナーの背後にあるバックエンド(Pod)が使用するプロトコルを指定するためにサービスで使用します。`http`(デフォルト)または`https`を指定すると、接続を終端してヘッダーを解析するHTTPSリスナーが生成されます。`ssl`または`tcp`を指定すると、「生の」SSLリスナーが使われます。`http`を指定して`aws-load-balancer-ssl-cert`を使わない場合は、HTTPリスナーが使われます。 * `service.beta.kubernetes.io/aws-load-balancer-ssl-cert`: セキュアなリスナーを要求するためにサービスで使用します。値は有効な証明書のARNです。詳細は、[ELBリスナーの設定](https://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-listener-config.html)を参照してください。CertARNは、IAMまたはCM証明書のARNで、例えば`arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012`のようになります。 * `service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled`: 接続ドレインを有効または無効にするためにサービスで使用します。 * `service.beta.kubernetes.io/aws-load-balancer-connection-draining-timeout`: 接続ドレインのタイムアウトを指定するためにサービスで使用します。 * `service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout`: アイドル接続タイムアウトを指定するためにサービスで使用します。 * `service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled`: クロスゾーン負荷分散を有効または無効にするためにサービスで使用されます。 * `service.beta.kubernetes.io/aws-load-balancer-security-groups`: 作成されたELBに追加するセキュリティーグループを指定するために使用します。これは、以前にELBに割り当てられた他のすべてのセキュリティーグループを置き換えます。ここで定義されたセキュリティーグループは、サービス間で共有してはいけません。 * `service.beta.kubernetes.io/aws-load-balancer-extra-security-groups`: 作成されたELBに加える追加のセキュリティーグループを指定するためにサービスで使用します。 * `service.beta.kubernetes.io/aws-load-balancer-internal`: 内部ELBが必要であることを示すためにサービスで使用します。 * `service.beta.kubernetes.io/aws-load-balancer-proxy-protocol`: ELB上でプロキシープロトコルを有効にするためにサービスで使用します。現在は、すべてのELBバックエンドでプロキシープロトコルを有効にすることを意味する`*`という値しか受け付けません。将来的には、特定のバックエンドでのみプロキシープロトコルを設定できるように調整できます。 * `service.beta.kubernetes.io/aws-load-balancer-ssl-ports`: SSL/HTTPSリスナーを使用するポートのコンマ区切りリストを指定するためにサービスで使用します。デフォルトは`*`(すべて)です。 AWSのアノテーションの情報は、[aws.go](https://github.com/kubernetes/legacy-cloud-providers/blob/master/aws/aws.go)のコメントから引用しています。 ## Azure この外部クラウドプロバイダーを利用したい場合、[kubernetes/cloud-provider-azure](https://github.com/kubernetes/cloud-provider-azure#readme)リポジトリーを参照してください。 ### ノード名 Azureクラウドプロバイダーは、ノードのホスト名(kubeletで決定されたもの、または`--hostname-override`で上書きされたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 Kubernetesノード名は、Azure VM名と一致しなければならないことに注意してください。 ## CloudStack この外部クラウドプロバイダーを利用したい場合、[apache/cloudstack-kubernetes-provider](https://github.com/apache/cloudstack-kubernetes-provider)リポジトリーを参照してください。 ### ノード名 CloudStackクラウドプロバイダーは、ノードのホスト名(kubeletで決定されたもの、または`--hostname-override`で上書きされたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 Kubernetesノード名は、CloudStack VM名と一致しなければならないことに注意してください。 ## GCE この外部クラウドプロバイダーを利用したい場合、[kubernetes/cloud-provider-gcp](https://github.com/kubernetes/cloud-provider-gcp#readme)リポジトリーを参照してください。 ### ノード名 GCEクラウドプロバイダーは、ノードのホスト名(kubeletで決定されたもの、または`--hostname-override`で上書きされたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 Kubernetesノード名の最初のセグメントは、GCEインスタンス名と一致しなければならないことに注意してください。例えば、`kubernetes-node-2.c.my-proj.internal`という名前のノードは、`kubernetes-node-2`という名前のインスタンスに対応していなければなりません。 ## HUAWEI CLOUD この外部クラウドプロバイダーを利用したい場合、[kubernetes-sigs/cloud-provider-huaweicloud](https://github.com/kubernetes-sigs/cloud-provider-huaweicloud)リポジトリーを参照してください。 ### ノード名 HUAWEI CLOUDプロバイダーは、ノードのプライベートIPアドレスをKubernetesノード名として使用します。 ノードでkubeletを開始するときは、必ず`--hostname-override=`を指定してください。 ## OpenStack ここでは、OpenStackでKubernetesを実行する際に使用できるすべての設定について説明します。 この外部クラウドプロバイダーを利用したい場合、[kubernetes/cloud-provider-openstack](https://github.com/kubernetes/cloud-provider-openstack#readme)リポジトリーを参照してください。 ### ノード名 OpenStackクラウドプロバイダーは、インスタンス名(OpenStackのメタデータで決定されたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 インスタンス名は必ず、Kubernetesノード名は、CloudStack VM名と一致しなければならないことに注意してください。 kubeletがNodeオブジェクトを正常に登録できるように、インスタンス名は有効なKubernetesノード名である必要があります。 ### サービス KubernetesのOpenStackクラウドプロバイダーの実装では、利用可能な場合、基盤となるクラウドからこれらのOpenStackのサービスの使用をサポートします。 | サービス名 | APIバージョン | 必須か | |--------------------------|----------------|----------| | Block Storage (Cinder) | V1†, V2, V3 | No | | Compute (Nova) | V2 | No | | Identity (Keystone) | V2‡, V3 | Yes | | Load Balancing (Neutron) | V1§, V2 | No | | Load Balancing (Octavia) | V2 | No | † Block Storage V1 APIのサポートは非推奨ですが、Kubernetes 1.9ではBlock Storage V3 APIのサポートが追加されました。 ‡ Identity V2 APIのサポートは非推奨となり、将来のリリースでプロバイダーから削除される予定です。「Queens」のリリース時点で、OpenStackはIdentity V2 APIを公開しません。 § Load Balancing V1 APIのサポートは、Kubernetes 1.9で削除されました。 サービスディスカバリーは、プロバイダー設定で提供される`auth-url`を使用して、OpenStack Identity(Keystone)が管理するサービスカタログを一覧表示することで実現されます。 プロバイダーは、Keystone以外のOpenStackサービスが利用できなくなった場合には、機能を緩やかに低下させ、影響を受ける機能のサポートを放棄します。 特定の機能は、基盤となるクラウドでNeutronが公開している拡張機能のリストに基づいて有効または無効にされます。 ### cloud.conf Kubernetesはcloud.confというファイルを介して、OpenStackとのやりとり方法を知っています。 これは、KubernetesにOpenStack認証エンドポイントの認証情報と場所を提供するファイルです。 ファイル内に以下の詳細を指定することで、cloud.confファイルを作成できます。 #### 典型的な設定 以下の設定例は、最も頻繁に設定が必要な値に関するものです。 プロバイダーをOpenStackクラウドのKeystoneエンドポイントに指定し、そのエンドポイントでの認証方法の詳細を提供し、さらにロードバランサーを設定します。 ```yaml [Global] username=user password=pass auth-url=https:///identity/v3 tenant-id=c869168a828847f39f7f06edd7305637 domain-id=2a73b8f597c04551a0fdc8e95544be8a [LoadBalancer] subnet-id=6937f8fa-858d-4bc9-a3a5-18d2c957166a ``` ##### グローバル これらのOpenStackプロバイダーの設定オプションは、グローバル設定に関連しており、`cloud.conf`ファイルの`[Global]`セクションに記述する必要があります。 * `auth-url`(必死): 認証に使用するKeystone APIのURLです。OpenStackのコントロールパネルでは、Access and Security > API Access > Credentialsで確認できます。 * `username`(必須): Keystoneに設定されている有効なユーザーのユーザー名を参照します。 * `password`(必須): Keystoneで設定された有効なユーザーのパスワードを参照します。 * `tenant-id`(必須): リソースを作成するプロジェクトのIDを指定するために使用します。 * `tenant-name`(任意): リソースを作成するプロジェクトの名前を指定します。 * `trust-id`(任意): 認証に使用するtrustの識別子を指定するために使用します。trustは、ユーザー(委託者)が他のユーザー(受託者)に役割を委譲したり、受託者が委託者になりすますことを許可したりする権限を表します。利用可能なtrustは、Keystone APIの`/v3/OS-TRUST/trusts`エンドポイントの下にあります。 * `domain-id`(任意): ユーザーが所属するドメインのIDを指定するために使用します。 * `domain-name`(任意): ユーザーが所属するドメイン名を指定するために使用します。 * `region`(任意): マルチリージョンのOpenStackクラウド上で実行する際に使うリージョンの識別子を指定するために使用します。リージョンはOpenStackデプロイメントの一般的な区分です。リージョンには厳密な地理的な意味合いはありませんが、デプロイメントでは`us-east`のような地理的な名前をリージョンの識別子に使うことができます。利用可能なリージョンはKeystone APIの`/v3/regions`エンドポイントの下にあります。 * `ca-file`(任意): カスタムCAファイルのパスを指定するために使用します。 テナントをプロジェクトに変更するKeystone V3を使用している場合、`tenant-id`の値は自動的にAPIのプロジェクト構造体にマッピングされます。 ##### ロードバランサー これらのOpenStackプロバイダーの設定オプションは、ロードバランサー設定に関連しており、`cloud.conf`ファイルの`[LoadBalancer]`セクションに記述する必要があります。 * `lb-version`(任意): 自動バージョン検出を上書きするために使用します。有効な値は`v1`または`v2`です。値が指定されていない場合、自動検出は基盤となるOpenStackクラウドが公開するサポートバージョンのうち、最も高いものを選択します。 * `use-octavia`(任意): Octavia LBaaS V2サービスカタログエンドポイントを探して、利用するかどうかを決定するために使用します。有効な値は`true`または`false`です。`true`が指定され、Octaiva LBaaS V2エントリーが見つからなかった場合、プロバイダーはフォールバックして代わりにNeutron LBaaS V2エンドポイントを見つけようとします。デフォルト値は`false` です。 * `subnet-id`(任意): ロードバランサーを作成したいサブネットのIDを指定します。Network > Networksにあります。サブネットを取得するには、それぞれのネットワークをクリックします。 * `floating-network-id`(任意): 指定した場合、ロードバランサーのフローティングIPを作成します。 * `lb-method`(任意): ロードバランサープールのメンバー間で負荷分散させるアルゴリズムを指定するために使用します。値には`ROUND_ROBIN`、`LEAST_CONNECTIONS`、`SOURCE_IP`を指定できます。何も指定しない場合のデフォルトの動作は`ROUND_ROBIN` です。 * `lb-provider`(任意): ロードバランサーのプロバイダーを指定するために使用します。指定しない場合は、Neutronで設定されたデフォルトのプロバイダサービスが使用されます。 * `create-monitor`(任意): Neutronロードバランサーのヘルスモニターを作成するかどうかを表します。有効な値は`true`と`false`で、デフォルト値は`false`です。`true`を指定した場合は、`monitor-delay`、`monitor-timeout`、`monitor-max-retries`も設定しなければなりません。 * `monitor-delay`(任意): ロードバランサーのメンバーにプローブを送信するまでの時間です。有効な時間単位を指定してください。有効な時間単位は\"ns\"、\"us\"(または\"μs\")、\"ms\"、\"s\"、\"m\"、\"h\"です。 * `monitor-timeout`(任意): モニタリングがタイムアウトする前にpingの応答を待つための最大の時間です。この値はdelay値よりも小さくする必要があります。有効な時間単位を指定してください。有効な時間単位は\"ns\"、\"us\"(または\"μs\")、\"ms\"、\"s\"、\"m\"、\"h\"です。 * `monitor-max-retries`(任意): ロードバランサーメンバーのステータスをINACTIVEに変更する前に許容されるpingの失敗の数です。1から10の間の数値でなければなりません。 * `manage-security-groups`(任意): ロードバランサーがセキュリティーグループのルールを自動的に管理するかどうかを決定します。有効な値は`true`と`false`で、デフォルト値は`false`です。`true`を指定した場合は、`node-security-group`も指定しなければなりません。 * `node-security-group`(任意): 管理するセキュリティーグループのIDです。 ##### ブロックストレージ これらのOpenStackプロバイダーの設定オプションは、ブロックストレージ設定に関連しており、`cloud.conf`ファイルの`[BlockStorage]`セクションに記述する必要があります。 * `bs-version`(任意): 自動バージョン検出を上書きするために使用します。有効な値は`v1`、`v2`、`v3`、`auto`です。`auto`が指定された場合、自動検出は基盤となるOpenStackクラウドが公開するサポートバージョンのうち、最も高いものを選択します。何も指定しない場合のデフォルト値は`auto`です。 * `trust-device-path`(任意): ほとんどのシナリオでは、Cinderが提供するブロックデバイス名(例: `/dev/vda`)は信頼できません。このブール値はこの動作をトグルします。`true`に設定すると、Cinderが提供するブロックデバイス名を信頼することになります。デフォルト値の`false`は、シリアル番号と`/dev/disk/by-id`のマッピングに基づいてデバイスのパスを検出します。 * `ignore-volume-az`(任意): Cinderボリュームをアタッチする際のアベイラビリティーゾーンの使用に影響を与えます。NovaとCinderのアベイラビリティーゾーンが異なる場合は、`true`に設定する必要があります。これは、Novaのアベイラビリティーゾーンが多くあるにも関わらず、Cinderのアベイラビリティーゾーンが1つしかない場合によく見られます。デフォルト値は以前のリリースで使用されていた動作を維持するために`false`になっていますが、将来的には変更される可能性があります。 * `node-volume-attach-limit`(任意): ノードにアタッチできるボリュームの最大数で、デフォルトはCinderの256です。 エンドポイントを区別するためにポートではなくパスを使用しているOpenStackデプロイメントにおいて、Kubernetesのバージョン1.8以下をデプロイする際、明示的に`bs-version`パラメーターの設定が必要な場合があります。パスベースのエンドポイントは`http://foo.bar/volume`の形式であり、ポートベースのエンドポイントは`http://foo.bar:xxx`の形式です。 パスベースのエンドポイントを使う環境で、Kubernetesが古い自動検出ロジックを使用している場合、ボリュームの切り離しを試みると`BS API version autodetection failed.`というエラーが返されます。この問題を回避するには、クラウドプロバイダー設定に以下のように追記することで、Cinder APIバージョン2を強制的に使用することができます。 ```yaml [BlockStorage] bs-version=v2 ``` ##### メタデータ これらのOpenStackプロバイダーの設定オプションは、メタデータ設定に関連しており、`cloud.conf`ファイルの`[Metadata]`セクションに記述する必要があります。 * `search-order`(任意): この設定のキーは、プロバイダーが実行するインスタンスに関連するメタデータの取得方法に影響します。デフォルト値の`configDrive,metadataService`について、プロバイダーは、コンフィグドライブが利用可能な場合は最初にインスタンスに関連するメタデータをそこから取得し、次にメタデータサービスから取得します。代替値は以下の通りです。 * `configDrive` - コンフィグドライブからのみ、インスタンスのメタデータを取得します。 * `metadataService` - メタデータサービスからのみ、インスタンスのメタデータを取得します。 * `metadataService,configDrive` - 最初にメタデータサービスからインスタンスのメタデータを取得し、次にコンフィグドライブから取得します。 コンフィグドライブ上のメタデータは時間の経過とともに陳腐化する可能性がありますが、メタデータサービスは常に最新の情報を提供するため、この動作を調整するのが望ましいです。しかし、すべてのOpenStackクラウドがコンフィグドライブとメタデータサービスの両方を提供しているわけではなく、どちらか一方しか利用できない場合もあるため、デフォルトでは両方をチェックするようになっています。 ##### ルート これらのOpenStackプロバイダーの設定オプションは、[kubenet](/ja/docs/concepts/cluster-administration/network-plugins/#kubenet)のKubernetesネットワークプラグインに関連しており、`cloud.conf`ファイルの`[Route]`セクションに記述する必要があります。 * `router-id`(任意): 基盤となるクラウドのNeutronデプロイメントが`extraroutes`拡張機能をサポートしている場合は、`router-id`を使用してルートを追加するルーターを指定します。選択したルーターは、クラスターノードを含むプライベートネットワークにまたがっていなければなりません(通常、ノードネットワークは1つしかないので、この値はノードネットワークのデフォルトルーターになります)。この値は、OpenStackで[kubenet](/docs/concepts/cluster-administration/network-plugins/#kubenet)を使用するために必要です。 ## OVirt ### ノード名 OVirtクラウドプロバイダーは、ノードのホスト名(kubeletで決定されたもの、または`--hostname-override`で上書きされたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 Kubernetesノード名は、VMのFQDN(`...`の下でOVirtによって報告されたもの)と一致しなければならないことに注意してください。 ## Photon ### ノード名 Photonクラウドプロバイダーは、ノードのホスト名(kubeletで決定されたもの、または`--hostname-override`で上書きされたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 Kubernetesノード名はPhoton VM名と一致しなければならないことに注意してください(もしくは、`--cloud-config`で`overrideIP`がtrueに設定されている場合は、Kubernetesノード名はPhoton VMのIPアドレスと一致しなければなりません)。 ## vSphere {{< tabs name=\"vSphere cloud provider\" >}} {{% tab name=\"vSphere 6.7U3以上\" %}} vSphere 6.7U3以上のすべてのvSphereデプロイメントでは、[external vSphere cloud provider](https://github.com/kubernetes/cloud-provider-vsphere)と[vSphere CSI driver](https://github.com/kubernetes-sigs/vsphere-csi-driver)の使用を推奨します。クイックスタートガイドについては、[Deploying a Kubernetes Cluster on vSphere with CSI and CPI](https://cloud-provider-vsphere.sigs.k8s.io/tutorials/kubernetes-on-vsphere-with-kubeadm.html)を参照してください。 {{% /tab %}} {{% tab name=\"vSphere 6.7U3未満\" %}} vSphere 6.7U3未満を実行している場合は、インツリーのvSphereクラウドプロバイダーを推奨します。クイックスタートガイドについては、[Running a Kubernetes Cluster on vSphere with kubeadm](https://cloud-provider-vsphere.sigs.k8s.io/tutorials/k8s-vcp-on-vsphere-with-kubeadm.html)を参照してください。 {{% /tab %}} {{< /tabs >}} vSphereクラウドプロバイダーの詳細なドキュメントについては、[vSphereクラウドプロバイダーのドキュメントサイト](https://cloud-provider-vsphere.sigs.k8s.io)を参照してください。 ## IBM Cloud Kubernetes Service ### コンピュートノード IBM Cloud Kubernetes Serviceプロバイダーを使用することで、仮想ノードと物理ノード(ベアメタル)を混在させたクラスターを単一のゾーン、またはリージョン内の複数のゾーンにまたがって作成することができます。詳細については、[Planning your cluster and worker node setup](https://cloud.ibm.com/docs/containers?topic=containers-planning_worker_nodes)を参照してください。 Kubernetes Nodeオブジェクトの名前は、IBM Cloud Kubernetes ServiceワーカーノードインスタンスのプライベートIPアドレスです。 ### ネットワーク IBM Cloud Kubernetes Serviceプロバイダーは、高品質なネットワークパフォーマンスとノードのネットワーク分離のためにVLANを提供します。カスタムファイアウォールやCalicoネットワークポリシーを設定して、クラスターにセキュリティーの追加レイヤーを加えたり、VPNを使用してクラスターをオンプレミスデータセンターに接続したりすることができます。詳細については、[Planning your cluster network setup](https://cloud.ibm.com/docs/containers?topic=containers-plan_clusters)を参照してください。 アプリケーションをパブリックまたはクラスター内で公開するには、NodePort、LoadBalancer、Ingressサービスを利用できます。また、Ingressアプリケーションのロードバランサーをアノテーションでカスタマイズすることもできます。詳細については、[Choosing an app exposure service](https://cloud.ibm.com/docs/containers?topic=containers-cs_network_planning#cs_network_planning)を参照してください。 ### ストレージ IBM Cloud Kubernetes Serviceプロバイダーは、Kubernetesネイティブの永続ボリュームを活用して、ユーザーがファイル、ブロック、およびクラウドオブジェクトストレージをアプリケーションにマウントできるようにします。また、データの永続ストレージにDatabase as a Serviceやサードパーティーのアドオンを使用することもできます。詳しくは、[Planning highly available persistent storage](https://cloud.ibm.com/docs/containers?topic=containers-storage_planning#storage_planning)を参照してください。 ## Baidu Cloud Container Engine ### ノード名 Baiduクラウドプロバイダーは、ノードのプライベートIPアドレス(kubeletで決定されたもの、または`--hostname-override`で上書きされたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 Kubernetesノード名はBaidu VMのプライベートIPと一致しなければならないことに注意してください。 ## Tencent Kubernetes Engine この外部クラウドプロバイダーを利用したい場合、[TencentCloud/tencentcloud-cloud-controller-manager](https://github.com/TencentCloud/tencentcloud-cloud-controller-manager)リポジトリーを参照してください。 ### ノード名 Baiduクラウドプロバイダーは、ノードのホスト名(kubeletで決定されたもの、または`--hostname-override`で上書きされたもの)を、Kubernetes Nodeオブジェクトの名前として使用します。 Kubernetesノード名はTencent VMのプライベートIPと一致しなければならないことに注意してください。 ## Alibaba Cloud Kubernetes この外部クラウドプロバイダーを利用したい場合、[kubernetes/cloud-provider-alibaba-cloud](https://github.com/kubernetes/cloud-provider-alibaba-cloud)リポジトリーを参照してください。 ### ノード名 Alibaba Cloudではノード名の書式は必要ありませんが、kubeletでは`--provider-id=${REGION_ID}.${INSTANCE_ID}`を追加する必要があります。パラメーター`${REGION_ID}`はKubernetesのリージョンのIDを、`${INSTANCE_ID}`はAlibaba ECS(Elastic Compute Service)のIDを表します。 ### ロードバランサー [アノテーション](https://www.alibabacloud.com/help/en/doc-detail/86531.htm)を設定することで、Alibaba Cloudの特定の機能を使用するように外部のロードバランサーを設定できます。 "} {"_id":"q-en-website-1b319bee184e279ba2e9a07490955fc847f7d2746626bff7bfb4bf51c01c7e2b","text":"* [kube-controller-manager](/docs/reference/command-line-tools-reference/kube-controller-manager/) - Kubernetesに同梱された、コアのコントロールループを埋め込むデーモンです。 * [kube-proxy](/docs/reference/command-line-tools-reference/kube-proxy/) - 単純なTCP/UDPストリームのフォワーディングや、一連のバックエンド間でTCP/UDPのラウンドロビンでのフォワーディングを実行できます。 * [kube-scheduler](/docs/reference/command-line-tools-reference/kube-scheduler/) - 可用性、パフォーマンス、およびキャパシティを管理するスケジューラーです。 * [kube-schedulerポリシー](/docs/reference/scheduling/policies) * [kube-schedulerプロファイル](/docs/reference/scheduling/profiles) * [kube-schedulerポリシー](/ja/docs/reference/scheduling/policies) * [Schedulerプロファイル](/ja/docs/reference/scheduling/config#プロファイル) * コントロールプレーンとワーカーノードで開いておくべき[ポートとプロトコル](/ja/docs/reference/networking/ports-and-protocols/)の一覧 ## 設定APIリファレンス このセクションでは、Kubernetesのコンポーネントやツールを設定するのに使われている「未公開」のAPIのドキュメントをまとめています。 クラスターを使ったり管理したりするユーザーやオペレーターにとって必要不可欠ではありますが、これらのAPIの大半はRESTful方式のAPIサーバーでは提供されません。 * [kubeconfig (v1)](/docs/reference/config-api/kubeconfig.v1/) * [kube-apiserver admission (v1)](/docs/reference/config-api/apiserver-admission.v1/) * [kube-apiserver configuration (v1alpha1)](/docs/reference/config-api/apiserver-config.v1alpha1/)および * [kube-apiserver configuration (v1beta1)](/docs/reference/config-api/apiserver-config.v1beta1/)および [kube-apiserver configuration (v1)](/docs/reference/config-api/apiserver-config.v1/) * [kube-apiserver encryption (v1)](/docs/reference/config-api/apiserver-encryption.v1/) * [kube-apiserver event rate limit (v1alpha1)](/docs/reference/config-api/apiserver-eventratelimit.v1alpha1/) * [kubelet configuration (v1alpha1)](/docs/reference/config-api/kubelet-config.v1alpha1/)および [kubelet configuration (v1beta1)](/docs/reference/config-api/kubelet-config.v1beta1/) [kubelet configuration (v1)](/docs/reference/config-api/kubelet-config.v1/) * [kubelet credential providers (v1alpha1)](/docs/reference/config-api/kubelet-credentialprovider.v1alpha1/)、 [kubelet credential providers (v1beta1)](/docs/reference/config-api/kubelet-credentialprovider.v1beta1/)および [kubelet credential providers (v1)](/docs/reference/config-api/kubelet-credentialprovider.v1/) * [kube-scheduler configuration (v1beta2)](/docs/reference/config-api/kube-scheduler-config.v1beta2/)、 [kube-scheduler configuration (v1beta3)](/docs/reference/config-api/kube-scheduler-config.v1beta3/)および [kube-scheduler configuration (v1)](/docs/reference/config-api/kube-scheduler-config.v1/) * [kube-controller-manager configuration (v1alpha1)](/docs/reference/config-api/kube-controller-manager-config.v1alpha1/) * [kube-proxy configuration (v1alpha1)](/docs/reference/config-api/kube-proxy-config.v1alpha1/) * [`audit.k8s.io/v1` API](/docs/reference/config-api/apiserver-audit.v1/) * [Client authentication API (v1beta1)](/docs/reference/config-api/client-authentication.v1beta1/)および [Client authentication API (v1)](/docs/reference/config-api/client-authentication.v1/) * [WebhookAdmission configuration (v1)](/docs/reference/config-api/apiserver-webhookadmission.v1/) * [ImagePolicy API (v1alpha1)](/docs/reference/config-api/imagepolicy.v1alpha1/) ## kubeadmの設定APIリファレンス * [v1beta3](/docs/reference/config-api/kubeadm-config.v1beta3/) ## 設計のドキュメント Kubernetesの機能に関する設計ドキュメントのアーカイブです。[Kubernetesアーキテクチャ](https://git.k8s.io/community/contributors/design-proposals/architecture/architecture.md) と[Kubernetesデザイン概要](https://git.k8s.io/community/contributors/design-proposals)から読み始めると良いでしょう。 Kubernetesの機能に関する設計ドキュメントのアーカイブです。[Kubernetesアーキテクチャ](https://git.k8s.io/community/contributors/design-proposals/architecture/architecture.md) と[Kubernetesデザイン概要](https://git.k8s.io/design-proposals-archive)から読み始めると良いでしょう。 "} {"_id":"q-en-website-1b9ef5fab246f59661743e884b7964edd50acb6daf4b05f110846c218022e821","text":"```shell kubectl apply -f services.yaml ``` 実行結果は下記のようになります。 ``` service/myservice created service/mydb created"} {"_id":"q-en-website-1c66ca62b0f1d7cc7a2d0f19a8f6ded05ec0d5818ce0ff527087a0803acfeb5f","text":"`Guaranteed` pods are guaranteed only when requests and limits are specified for all the containers and they are equal. These pods will never be evicted because of another pod's resource consumption. If a system daemon (such as `kubelet`, `docker`, and `journald`) is consuming more resources than were reserved via and `journald`) is consuming more resources than were reserved via `system-reserved` or `kube-reserved` allocations, and the node only has `Guaranteed` or `Burstable` pods using less resources than requests left on it, then the kubelet must choose to evict one of these pods to preserve node stability"} {"_id":"q-en-website-1d93df0b5443343f8a09ddaeda8d38983f8718030eb42036d75144b37a806968","text":"1. Download the latest release with the command: ```bash {{< tabs name=\"download_convert_binary_linux\" >}} {{< tab name=\"x86-64\" codelang=\"bash\" >}} curl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert\" ``` {{< /tab >}} {{< tab name=\"ARM64\" codelang=\"bash\" >}} curl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl-convert\" {{< /tab >}} {{< /tabs >}} 1. Validate the binary (optional) Download the kubectl-convert checksum file: ```bash {{< tabs name=\"download_convert_checksum_linux\" >}} {{< tab name=\"x86-64\" codelang=\"bash\" >}} curl -LO \"https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert.sha256\" ``` {{< /tab >}} {{< tab name=\"ARM64\" codelang=\"bash\" >}} curl -LO \"https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl-convert.sha256\" {{< /tab >}} {{< /tabs >}} Validate the kubectl-convert binary against the checksum file:"} {"_id":"q-en-website-1ed66f9c2f3bb1b4e2f72141c5ab03abcc0e3a2d53a93251ce16479179666237","text":"--- title: Workload id: workloads id: workload date: 2019-02-13 full_link: /docs/concepts/workloads/ short_description: >"} {"_id":"q-en-website-1f0ea27053853e86cc163013d137453c6161d266e136eeee69b8a58972d77de3","text":"The output is similar to this: NAME READY UP-TO-DATE AVAILABLE AGE NAME READY UP-TO-DATE AVAILABLE AGE ... dns-autoscaler 1/1 1 1 ... kube-dns-autoscaler 1/1 1 1 ... ... If you see \"dns-autoscaler\" in the output, DNS horizontal autoscaling is If you see \"kube-dns-autoscaler\" in the output, DNS horizontal autoscaling is already enabled, and you can skip to [Tuning autoscaling parameters](#tuning-autoscaling-parameters)."} {"_id":"q-en-website-1f75261602bcd19ea0b8a82fd25920bd8f5bd719824882ab1e6e494a5db9a718","text":" You need to have shell access to all the nodes, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. "} {"_id":"q-en-website-1fa2a87f9d03a046c19d1dd6fffc47313325531440d18afe554b62449579d7f2","text":" --- title: ConfigMap id: configmap date: 2018-04-12 full_link: /ja/docs/concepts/configuration/configmap/ short_description: > 機密性のないデータをキーと値のペアで保存するために使用されるAPIオブジェクトです。環境変数、コマンドライン引数、またはボリューム内の設定ファイルとして使用できます。 aka: tags: - core-object --- 機密性のないデータをキーと値のペアで保存するために使用されるAPIオブジェクトです。{{< glossary_tooltip text=\"Pod\" term_id=\"pod\" >}}は、環境変数、コマンドライン引数、または{{< glossary_tooltip text=\"ボリューム\" term_id=\"volume\" >}}内の設定ファイルとしてConfigMapを使用できます。 ConfigMapを使用すると、環境固有の設定を{{< glossary_tooltip text=\"コンテナイメージ\" term_id=\"image\" >}}から分離できるため、アプリケーションを簡単に移植できるようになります。 "} {"_id":"q-en-website-203f37b200db88b91a4eaa11287ab731a304e7e130d4cc61e721bad6ae63d95a","text":" --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: default-deny-egress spec: podSelector: {} policyTypes: - Egress "} {"_id":"q-en-website-212e112d3780964d15e7ca0470d7b3c8b7d83fda93d5879b4f7136475d4a4119","text":"We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */

{{ T \"main_kubeweekly_baseline\" }}


"} {"_id":"q-en-website-2195eb1cb992192de73e64980dbf76386a540d331fea42cf0b16d3904883ca9d","text":"max_line_length = 80 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false [*.{css,html,js,json,sass,md,mmark,toml,yaml}] indent_style = space indent_size = 2"} {"_id":"q-en-website-21cf11b49e498fe2b74a12a9f76ff1ebdec69534cc6ced5fb2d2b5fd9e24cb16","text":"} ``` Non-resource paths include: `/api`, `/apis`, `/metrics`, `/resetMetrics`, `/logs`, `/debug`, `/healthz`, `/swagger-ui/`, `/swaggerapi/`, `/ui`, and Non-resource paths include: `/api`, `/apis`, `/metrics`, `/logs`, `/debug`, `/healthz`, `/livez`, `/openapi/v2`, `/readyz`, and `/version.` Clients require access to `/api`, `/api/*`, `/apis`, `/apis/*`, and `/version` to discover what resources and versions are present on the server. Access to other non-resource paths can be disallowed without restricting access"} {"_id":"q-en-website-22c0f22b2b5c1a519d3775645dc4efffec4e776f192786cbc7faee712209fb68","text":"Pod level control groups (cgroups) are based on the effective Pod request and limit, the same as the scheduler. {{< comment >}} This section also present under [sidecar containers](/docs/concepts/workloads/pods/sidecar-containers/) page. If you're editing this section, change both places. {{< /comment >}} ### Pod restart reasons"} {"_id":"q-en-website-22cc306c3156634b7a303125a7673ee8b63ea46d9c120d69d8a17eb0bdea3759","text":"### Metrics {{< note >}} In versions of Kubernetes before v1.20, the labels `flow_schema` and `priority_level` were inconsistently named `flowSchema` and `priorityLevel`, respectively. If you're running Kubernetes versions v1.19 and earlier, you should refer to the documentation for your version. {{< /note >}} When you enable the API Priority and Fairness feature, the kube-apiserver exports additional metrics. Monitoring these can help you determine whether your configuration is inappropriately throttling important traffic, or find"} {"_id":"q-en-website-296fcaf6116c62d075df414be1ba2af36e409f6a99f80b33be79a4f9f198669a","text":"main_menu: true weight: 70 content_type: concept no_list: true --- 本セクションには、Kubernetesのドキュメントのリファレンスが含まれています。 ## APIリファレンス * [Kubernetes API概要](/docs/reference/using-api/) - Kubernetes APIの概要です。 * [Kubernetes APIリファレンス {{< latest-version >}}](/docs/reference/generated/kubernetes-api/{{< latest-version >}}/) * [標準化用語集](/ja/docs/reference/glossary) - Kubernetesの用語の包括的で標準化されたリストです。 * [Kubernetes APIリファレンス](/docs/reference/using-api/) * [Kubernetes {{< param \"version\" >}}の単一ページのAPIリファレンス](/docs/reference/generated/kubernetes-api/{{< param \"version\" >}}/) * [Kubernetes APIの使用](/ja/docs/reference/using-api/) - KubernetesのAPIの概要です。 * [API アクセスコントロール](/docs/reference/access-authn-authz/) - KubernetesがAPIアクセスをどのように制御するかの詳細です。 * [よく知られたラベル、アノテーション、テイント](/docs/reference/labels-annotations-taints/) ## APIクライアントライブラリー ## 公式にサポートされているクライアントライブラリー プログラミング言語からKubernetesのAPIを呼ぶためには、[クライアントライブラリー](/docs/reference/using-api/client-libraries/)を使うことができます。公式にサポートしているクライアントライブラリー:"} {"_id":"q-en-website-2b645f1714025727ee4c2789a309282e61c5216e6a3616f9b88772518cc20e72","text":"Kubelet auto-discovers these filesystems and ignores other filesystems. Kubelet does not support other configurations. {{}} Some kubelet garbage collection features are deprecated in favor of eviction. For a list of the deprecated features, see [kubelet garbage collection deprecation](/docs/concepts/architecture/garbage-collection/#deprecation). {{}} Some kubelet garbage collection features are deprecated in favor of eviction: | Existing Flag | New Flag | Rationale | | ------------- | -------- | --------- | | `--image-gc-high-threshold` | `--eviction-hard` or `--eviction-soft` | existing eviction signals can trigger image garbage collection | | `--image-gc-low-threshold` | `--eviction-minimum-reclaim` | eviction reclaims achieve the same behavior | | `--maximum-dead-containers` | | deprecated once old logs are stored outside of container's context | | `--maximum-dead-containers-per-container` | | deprecated once old logs are stored outside of container's context | | `--minimum-container-ttl-duration` | | deprecated once old logs are stored outside of container's context | ### Eviction thresholds"} {"_id":"q-en-website-2c0c555c3434db3fe855847dfb2155065ee869b1d9b6ecfa8670fb3766f103b1","text":"If you would like to write a concept page, see [Page Content Types](/docs/home/contribute/style/page-content-types/#concept) [Page Content Types](/docs/contribute/style/page-content-types/#concept) for information about the concept page types."} {"_id":"q-en-website-2c95abf77ef2dee09d081cf4927a5c11b56b162c0a0a6634b8dcaa128b0e73bc","text":" --- layout: blog title: \"Kubernetes v1.28:可追溯的默认 StorageClass 进阶至 GA\" date: 2023-08-18 slug: retroactive-default-storage-class-ga --- **作者:** Roman Bednář (Red Hat) **译者:** [Michael Yao](https://github.com/windsonsea) (DaoCloud) 可追溯的默认 StorageClass 赋值(Retroactive Default StorageClass Assignment)在 Kubernetes v1.28 中宣布进阶至正式发布(GA)! Kubernetes SIG Storage 团队非常高兴地宣布,在 Kubernetes v1.25 中作为 Alpha 特性引入的 “可追溯默认 StorageClass 赋值” 现已进阶至 GA, 并正式成为 Kubernetes v1.28 发行版的一部分。 这项增强特性极大地改进了默认的 [StorageClasses](/zh-cn/docs/concepts/storage/storage-classes/) 为 PersistentVolumeClaim (PVC) 赋值的方式。 启用此特性后,你不再需要先创建默认的 StorageClass,再创建 PVC 来指定存储类。 现在,未分配 StorageClass 的所有 PVC 都将被自动更新为包含默认的 StorageClass。 此项增强特性确保即使默认的 StorageClass 在 PVC 创建时未被定义, PVC 也不会再滞留在未绑定状态,存储制备工作可以无缝进行。 ## 有什么变化? {#what-changed} PersistentVolume (PV) 控制器已修改为:当未设置 `storageClassName` 时,自动向任何未绑定的 PersistentVolumeClaim 分配一个默认的 StorageClass。此外,API 服务器中的 PersistentVolumeClaim 准入验证机制也已调整为允许将值从未设置状态更改为实际的 StorageClass 名称。 ## 如何使用? {#how-to-use-it} 由于此特性已进阶至 GA,所以不再需要启用特性门控。 只需确保你运行的是 Kubernetes v1.28 或更高版本,此特性即可供使用。 有关更多细节,可以查阅 Kubernetes 文档中的[默认 StorageClass 赋值](/zh-cn/docs/concepts/storage/persistent-volumes/#retroactive-default-storageclass-assignment)。 你也可以阅读以前在 v1.26 中宣布进阶至 Beta 的[博客文章](/zh-cn/blog/2023/01/05/retroactive-default-storage-class/)。 要提供反馈,请加入我们的 [Kubernetes 存储特别兴趣小组](https://github.com/kubernetes/community/tree/master/sig-storage) (SIG) 或参与[公共 Slack 频道](https://app.slack.com/client/T09NY5SBT/C09QZFCE5)上的讨论。 "} {"_id":"q-en-website-2ca184619ef4caf0e5cc95e80f5cc4b5d3df8ec5275af5a182e093275d127ce6","text":" --- title: Kindを使用してKubernetesをインストールする weight: 40 content_type: concept --- Kindは、Dockerコンテナをノードとして使用して、ローカルのKubernetesクラスターを実行するためのツールです。 ## インストール [Kindをインストールする](https://kind.sigs.k8s.io/docs/user/quick-start/)を参照してください。 "} {"_id":"q-en-website-2ce02b5e125a9f0426e33b42cb3a04fff0c5f588e26bcdb7a7d4c33842816428","text":"{{< tab name=\"bootstrap-token\" include=\"generated/kubeadm_init_phase_bootstrap-token.md\" />}} {{< /tabs >}} ## kubeadm init phase kubelet-finialize {#cmd-phase-kubelet-finalize-all} Use the following phase to update settings relevant to the kubelet after TLS bootstrap. You can use the `all` subcommand to run all `kubelet-finalize` phases. {{< tabs name=\"tab-kubelet-finalize\" >}} {{< tab name=\"kublet-finalize\" include=\"generated/kubeadm_init_phase_kubelet-finalize.md\" />}} {{< tab name=\"kublet-finalize-all\" include=\"generated/kubeadm_init_phase_kubelet-finalize_all.md\" />}} {{< tab name=\"kublet-finalize-cert-rotation\" include=\"generated/kubeadm_init_phase_kubelet-finalize_experimental-cert-rotation.md\" />}} {{< /tabs >}} ## kubeadm init phase addon {#cmd-phase-addon}"} {"_id":"q-en-website-2d33b3b17748227bc97bdf475e443f48a2212cfafea41b7df878994703ac9415","text":"```shell kubectl get -f myapp.yaml ``` 実行結果は下記のようになります。 ``` NAME READY STATUS RESTARTS AGE myapp-pod 0/1 Init:0/2 0 6m"} {"_id":"q-en-website-2d4ba3fe1272f449fd8febc84bfa24ecde412fcc5370c7261587b115dcfcc0a6","text":"## {{% heading \"prerequisites\" %}} {{< include \"task-tutorial-prereqs.md\" >}} {{< version-check >}} {{< include \"task-tutorial-prereqs-node-upgrade.md\" >}} {{< version-check >}} * Familiarize yourself with [the process for upgrading the rest of your kubeadm cluster](/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade). You will want to upgrade the control plane nodes before upgrading your Windows nodes."} {"_id":"q-en-website-2fc8dbbaf61e6eeef4b0b239b038d93c40e71e1064a063cb727e5aa52a814247","text":"### Weave Net from Weaveworks [Weave Net](https://www.weave.works/products/weave-net/) is a [Weave Net](https://www.weave.works/oss/net/) is a resilient and simple to use network for Kubernetes and its hosted applications. Weave Net runs as a [CNI plug-in](https://www.weave.works/docs/net/latest/cni-plugin/) or stand-alone. In either version, it doesn't require any configuration or extra code"} {"_id":"q-en-website-32d569d82780a5d083ac97950547930168ab3c01f4c0e721d5f38d5748ea399b","text":" --- layout: blog title: \"确保准入控制器的安全\" date: 2022-01-19 slug: secure-your-admission-controllers-and-webhooks --- **作者:** Rory McCune (Aqua Security) [准入控制](/zh/docs/reference/access-authn-authz/admission-controllers/)和认证、授权都是 Kubernetes 安全性的关键部分。 Webhook 准入控制器被广泛用于以多种方式帮助提高 Kubernetes 集群的安全性, 包括限制工作负载权限和确保部署到集群的镜像满足组织安全要求。 然而,与添加到集群中的任何其他组件一样,安全风险也会随之出现。 一个安全风险示例是没有正确处理准入控制器的部署和管理。 为了帮助准入控制器用户和设计人员适当地管理这些风险, SIG Security 的[安全文档](https://github.com/kubernetes/community/tree/master/sig-security#security-docs)小组 花费了一些时间来开发一个[准入控制器威胁模型](https://github.com/kubernetes/sig-security/tree/main/sig-security-docs/papers/admission-control)。 这种威胁模型着眼于由于不正确使用准入控制器而产生的可能的风险,可能允许绕过安全策略,甚至允许攻击者未经授权访问集群。 基于这个威胁模型,我们开发了一套安全最佳实践。 你应该采用这些实践来确保集群操作员可以获得准入控制器带来的安全优势,同时避免使用它们带来的任何风险。 ## 准入控制器和安全的良好做法 基于这个威胁模型,围绕着如何确保准入控制器的安全性出现了几个主题。 ### 安全的 webhook 配置 确保集群中的任何安全组件都配置良好是很重要的,在这里准入控制器也并不例外。 使用准入控制器时需要考虑几个安全最佳实践: * **为所有 webhook 流量正确配置了 TLS**。 API 服务器和准入控制器 webhook 之间的通信应该经过身份验证和加密,以确保处于网络中查看或修改此流量的攻击者无法查看或修改。 要实现此访问,API 服务器和 webhook 必须使用来自受信任的证书颁发机构的证书,以便它们可以验证相互的身份。 * **只允许经过身份验证的访问**。 如果攻击者可以向准入控制器发送大量请求,他们可能会压垮服务导致其失败。 确保所有访问都需要强身份验证可以降低这种风险。 * **准入控制器关闭失败**。 这是一种需要权衡的安全实践,集群操作员是否要对其进行配置取决于集群的威胁模型。 如果一个准入控制器关闭失败,当 API 服务器无法从它得到响应时,所有的部署都会失败。 这可以阻止攻击者通过禁用准入控制器绕过准入控制器,但可能会破坏集群的运行。 由于集群可以有多个 webhook,因此一种折中的方法是对关键控制允许故障关闭, 并允许不太关键的控制进行故障打开。 * **定期审查 webhook 配置**。 配置错误可能导致安全问题,因此检查准入控制器 webhook 配置以确保设置正确非常重要。 这种审查可以由基础设施即代码扫描程序自动完成,也可以由管理员手动完成。 ### 为准入控制保护集群配置 在大多数情况下,集群使用的准入控制器 webhook 将作为工作负载安装在集群中。 因此,确保正确配置了可能影响其操作的 Kubernetes 安全特性非常重要。 * **限制 [RBAC](/zh/docs/reference/access-authn-authz/rbac/) 权限**。 任何有权修改 webhook 对象的配置或准入控制器使用的工作负载的用户都可以破坏其运行。 因此,确保只有集群管理员拥有这些权限非常重要。 * **防止特权工作负载**。 容器系统的一个现实是,如果工作负载被赋予某些特权, 则有可能逃逸到下层的集群节点并影响该节点上的其他容器。 如果准入控制器服务在它们所保护的集群上运行, 一定要确保对特权工作负载的所有请求都要经过仔细审查并尽可能地加以限制。 * **严格控制外部系统访问**。 作为集群中的安全服务,准入控制器系统将有权访问敏感信息,如凭证。 为了降低此信息被发送到集群外的风险, 应使用[网络策略](/zh/docs/concepts/services-networking/network-policies/) 来限制准入控制器服务对外部网络的访问。 * **每个集群都有一个专用的 webhook**。 虽然可能让准入控制器 webhook 服务于多个集群的, 但在使用该模型时存在对 webhook 服务的攻击会对共享它的地方产生更大影响的风险。 此外,在多个集群使用准入控制器的情况下,复杂性和访问要求也会增加,从而更难保护其安全。 ### 准入控制器规则 对于用于 Kubernetes 安全的所有准入控制器而言,一个关键元素是它使用的规则库。 规则需要能够准确地满足其目标,避免假阳性和假阴性结果。 * **定期测试和审查规则**。 需要测试准入控制器规则以确保其准确性。 还需要定期审查,因为 Kubernetes API 会随着每个新版本而改变, 并且需要在每个 Kubernetes 版本中评估规则,以了解使他们保持最新版本所需要做的任何改变。 No newline at end of file"} {"_id":"q-en-website-32f98857ace0affa5292646b0169ac5d25825bb52a7637d028694f190cca91e4","text":"from the community. Please try it out and give us feedback! {{< /caution >}} ## kubeadm alpha certs {#cmd-certs} A collection of operations for operating Kubernetes certificates. {{< tabs name=\"tab-certs\" >}} {{< tab name=\"overview\" include=\"generated/kubeadm_alpha_certs.md\" />}} {{< /tabs >}} ## kubeadm alpha certs renew {#cmd-certs-renew} You can renew all Kubernetes certificates using the `all` subcommand or renew them selectively."} {"_id":"q-en-website-3308fe535b661c0bede75d6ea644ffc6edd5aaa0c817bce38a96ba8be372e2ef","text":"known endpoints. To use different container runtime or if there are more than one installed on the provisioned node, specify the `--cri-socket` argument to `kubeadm`. See [Installing a runtime](/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-runtime). 1. (Optional) Unless otherwise specified, `kubeadm` uses the network interface associated with the default gateway to set the advertise address for this particular control-plane node's API server. To use a different network interface, specify the `--apiserver-advertise-address=` argument to `kubeadm init`. To deploy an IPv6 Kubernetes cluster using IPv6 addressing, you must specify an IPv6 address, for example `--apiserver-advertise-address=2001:db8::101` To initialize the control-plane node run:"} {"_id":"q-en-website-3392ca316c0f6f68db2cfee0574d87ac95592509c2130da527ca6d2dc38a1058","text":"### rbd `rbd` 볼륨을 사용하면 [Rados Block Device](https://ceph.com/docs/master/rbd/rbd/)(RBD) 볼륨을 파드에 마운트할 수 [Rados Block Device](https://docs.ceph.com/en/latest/rbd/)(RBD) 볼륨을 파드에 마운트할 수 있다. 파드를 제거할 때 지워지는 `emptyDir` 와는 다르게 `rbd` 볼륨의 내용은 유지되고, 볼륨은 마운트 해제만 된다. 이 의미는 RBD 볼륨에 데이터를 미리 채울 수 있으며, 데이터를"} {"_id":"q-en-website-3500ef8a6c375aea5b8dc123332bcf0cc92b11081422d751bde6d9f1addfd28c","text":"The Kubernetes project uses an automation tool called prow for automation related to GitHub issues and pull requests. The [Kubernetes website repository](https://github.com/kubernetes/website) uses two [prow plugins](https://github.com/kubernetes/test-infra/tree/master/prow/plugins): two [prow plugins](https://github.com/kubernetes-sigs/prow/tree/main/pkg/plugins): - blunderbuss - approve"} {"_id":"q-en-website-3510a97367a8958ee100dc8ba16d785775de68f4657beb5477babac0749f318f","text":"--- title: Service Accounts description: > Learn about the Kubernetes ServiceAccount object. Learn about ServiceAccount objects in Kubernetes. content_type: concept weight: 10 ---"} {"_id":"q-en-website-35354c9e05afb4d42662d0575327f179e0fe4a08f6e86eb93abe1eae956d6abf","text":"* `TYPE`: Specifies the [resource type](#resource-types). Resource types are case-insensitive and you can specify the singular, plural, or abbreviated forms. For example, the following commands produce the same output: ```shell kubectl get pod pod1 kubectl get pods pod1 kubectl get po pod1 ``` ```shell kubectl get pod pod1 kubectl get pods pod1 kubectl get po pod1 ``` * `NAME`: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed, for example `kubectl get pods`."} {"_id":"q-en-website-37702b65234a003ceb838beb23b946080752b4e0188ca34c3d8cf19c43b6b1e6","text":" --- title: \"macOS 系统上的 bash 自动补全\" description: \"在 macOS 上实现 Bash 自动补全的一些可选配置。\" headless: true --- ### 简介 kubectl 的 Bash 补全脚本可以通过 `kubectl completion bash` 命令生成。 在你的 shell 中导入(Sourcing)这个脚本即可启用补全功能。 此外,kubectl 补全脚本依赖于工具 [**bash-completion**](https://github.com/scop/bash-completion), 所以你必须先安装它。 {{< warning>}} bash-completion 有两个版本:v1 和 v2。v1 对应 Bash3.2(也是 macOS 的默认安装版本),v2 对应 Bash 4.1+。 kubectl 的补全脚本**无法适配** bash-completion v1 和 Bash 3.2。 必须为它配备 **bash-completion v2** 和 **Bash 4.1+**。 有鉴于此,为了在 macOS 上使用 kubectl 补全功能,你必须要安装和使用 Bash 4.1+ ([*说明*](https://itnext.io/upgrading-bash-on-macos-7138bd1066ba))。 后续说明假定你用的是 Bash 4.1+(也就是 Bash 4.1 或更新的版本) {{< /warning >}} ### 升级 Bash 后续说明假定你已使用 Bash 4.1+。你可以运行以下命令检查 Bash 版本: ```bash echo $BASH_VERSION ``` 如果版本太旧,可以用 Homebrew 安装/升级: ```bash brew install bash ``` 重新加载 shell,并验证所需的版本已经生效: ```bash echo $BASH_VERSION $SHELL ``` Homebrew 通常把它安装为 `/usr/local/bin/bash`。 ### 安装 bash-completion {{< note >}} 如前所述,本说明假定你使用的 Bash 版本为 4.1+,这意味着你要安装 bash-completion v2 (不同于 Bash 3.2 和 bash-completion v1,kubectl 的补全功能在该场景下无法工作)。 {{< /note >}} 你可以用命令 `type _init_completion` 测试 bash-completion v2 是否已经安装。 如未安装,用 Homebrew 来安装它: ```bash brew install bash-completion@2 ``` 如命令的输出信息所显示的,将如下内容添加到文件 `~/.bash_profile` 中: ```bash export BASH_COMPLETION_COMPAT_DIR=\"/usr/local/etc/bash_completion.d\" [[ -r \"/usr/local/etc/profile.d/bash_completion.sh\" ]] && . \"/usr/local/etc/profile.d/bash_completion.sh\" ``` 重新加载 shell,并用命令 `type _init_completion` 验证 bash-completion v2 已经恰当的安装。 ### 启用 kubectl 自动补全功能 你现在需要确保在所有的 shell 环境中均已导入(sourced) kubectl 的补全脚本, 有若干种方法可以实现这一点: - 在文件 `~/.bash_profile` 中导入(Source)补全脚本: ```bash echo 'source <(kubectl completion bash)' >>~/.bash_profile ``` - 将补全脚本添加到目录 `/usr/local/etc/bash_completion.d` 中: ```bash kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl ``` - 如果你为 kubectl 定义了别名,则可以扩展 shell 补全来兼容该别名: ```bash echo 'alias k=kubectl' >>~/.bash_profile echo 'complete -F __start_kubectl k' >>~/.bash_profile ``` - 如果你是用 Homebrew 安装的 kubectl([如上所述](#install-with-homebrew-on-macos)), 那么 kubectl 补全脚本应该已经安装到目录 `/usr/local/etc/bash_completion.d/kubectl` 中了。 这种情况下,你什么都不需要做。 {{< note >}} 用 Hommbrew 安装的 bash-completion v2 会初始化 目录 `BASH_COMPLETION_COMPAT_DIR` 中的所有文件,这就是后两种方法能正常工作的原因。 {{< /note >}} 总之,重新加载 shell 之后,kubectl 补全功能将立即生效。 "} {"_id":"q-en-website-37e76407529bbfedcf8b3bbc2c9d7a7704f723a65ef5b19a2f6e349cf1676f18","text":"[plugin](/docs/concepts/storage/volumes/#types-of-volumes). The following broad classes of Kubernetes volume plugins are supported on Windows: * [`FlexVolume plugins`](/docs/concepts/storage/volumes/#flexvolume-deprecated) * [`FlexVolume plugins`](/docs/concepts/storage/volumes/#flexvolume) * Please note that FlexVolumes have been deprecated as of 1.23 * [`CSI Plugins`](/docs/concepts/storage/volumes/#csi)"} {"_id":"q-en-website-3863da7166b07bbc93e8e2d322792353b854dcf594d995d2d4bbd90bbbad526e","text":"**only do this in a test cluster**. ```shell kubectl drain --force --delete-local-data --ignore-daemonsets kubectl drain --force --delete-emptydir-data --ignore-daemonsets ``` Now you can watch as the Pod reschedules on a different Node:"} {"_id":"q-en-website-38fbbe4e41a661735453e6ae6ce887ca774d3d9f0353eebec8cb8fc2167a2026","text":" {{ end }}

{{ .message | markdownify }}

{{- if eq .dismissParameters.dismissible true -}} {{- end -}}
"} {"_id":"q-en-website-39b5d388fb2ac51998e82fdbd58f0d18fea7e66fa1a3402ae814537726f420a8","text":" --- title: Secret id: secret date: 2018-04-12 full_link: /ja/docs/concepts/configuration/secret/ short_description: > パスワードやOAuthトークン、SSHキーのような機密の情報を保持します。 aka: tags: - core-object - security --- パスワードやOAuthトークン、SSHキーのような機密の情報を保持します。 機密情報の取り扱い方法を細かく制御することができ、保存時には[暗号化](/ja/docs/tasks/administer-cluster/encrypt-data/#ensure-all-secrets-are-encrypted)するなど、誤って公開してしまうリスクを減らすことができます。{{< glossary_tooltip text=\"Pod\" term_id=\"pod\" >}}は、ボリュームマウントされたファイルとして、またはPodのイメージをPullするkubeletによって、Secretを参照します。Secretは機密情報を扱うのに最適で、機密でない情報には[ConfigMap](/ja/docs/tasks/configure-pod-container/configure-pod-configmap/)が適しています。 "} {"_id":"q-en-website-3a77b7d32d2f266fa3c16e6e5bf28d02b349e1ac138fac0a4d45dd6ce7470f44","text":"title: Extending the Kubernetes API weight: 30 --- Custom resources are extensions of the Kubernetes API. Kubernetes provides two ways to add custom resources to your cluster: - The [CustomResourceDefinition](/docs/concepts/extend-kubernetes/api-extension/custom-resources/) (CRD) mechanism allows you to declaratively define a new custom API with an API group, kind, and schema that you specify. The Kubernetes control plane serves and handles the storage of your custom resource. CRDs allow you to create new types of resources for your cluster without writing and running a custom API server. - The [aggregation layer](/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/) sits behind the primary API server, which acts as a proxy. This arrangement is called API Aggregation (AA), which allows you to provide specialized implementations for your custom resources by writing and deploying your own API server. The main API server delegates requests to your API server for the custom APIs that you specify, making them available to all of its clients. "} {"_id":"q-en-website-3b5f0d195ffc236ff2a763672a36c8bd3f345448ff145d483e5a70fad78b40ff","text":" --- title: Pod 拓扑分布约束 content_type: concept weight: 40 --- 你可以使用 _拓扑分布约束(Topology Spread Constraints)_ 来控制 {{< glossary_tooltip text=\"Pod\" term_id=\"Pod\" >}} 在集群内故障域之间的分布, 例如区域(Region)、可用区(Zone)、节点和其他用户自定义拓扑域。 这样做有助于实现高可用并提升资源利用率。 ## 先决条件 {#prerequisites} ### 节点标签 {#node-labels} 拓扑分布约束依赖于节点标签来标识每个节点所在的拓扑域。 例如,某节点可能具有标签:`node=node1,zone=us-east-1a,region=us-east-1` 假设你拥有具有以下标签的一个 4 节点集群: ``` NAME STATUS ROLES AGE VERSION LABELS node1 Ready 4m26s v1.16.0 node=node1,zone=zoneA node2 Ready 3m58s v1.16.0 node=node2,zone=zoneA node3 Ready 3m17s v1.16.0 node=node3,zone=zoneB node4 Ready 2m43s v1.16.0 node=node4,zone=zoneB ``` 那么,从逻辑上看集群如下: {{}} graph TB subgraph \"zoneB\" n3(Node3) n4(Node4) end subgraph \"zoneA\" n1(Node1) n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4 k8s; class zoneA,zoneB cluster; {{< /mermaid >}} 你可以复用在大多数集群上自动创建和填充的[常用标签](/zh-cn/docs/reference/labels-annotations-taints/), 而不是手动添加标签。 ## Pod 的分布约束 {#spread-constraints-for-pods} ### API `pod.spec.topologySpreadConstraints` 字段定义如下所示: ```yaml apiVersion: v1 kind: Pod metadata: name: mypod spec: topologySpreadConstraints: - maxSkew: topologyKey: whenUnsatisfiable: labelSelector: ``` 你可以定义一个或多个 `topologySpreadConstraint` 来指示 kube-scheduler 如何根据与现有的 Pod 的关联关系将每个传入的 Pod 部署到集群中。字段包括: - **maxSkew** 描述 Pod 分布不均的程度。这是给定拓扑类型中任意两个拓扑域中匹配的 Pod 之间的最大允许差值。它必须大于零。取决于 `whenUnsatisfiable` 的取值, 其语义会有不同。 - 当 `whenUnsatisfiable` 等于 \"DoNotSchedule\" 时,`maxSkew` 是目标拓扑域中匹配的 Pod 数与全局最小值(一个拓扑域中与标签选择器匹配的 Pod 的最小数量。例如,如果你有 3 个区域,分别具有 0 个、2 个 和 3 个匹配的 Pod,则全局最小值为 0。)之间可存在的差异。 - 当 `whenUnsatisfiable` 等于 \"ScheduleAnyway\" 时,调度器会更为偏向能够降低偏差值的拓扑域。 - **minDomains** 表示符合条件的域的最小数量。域是拓扑的一个特定实例。 符合条件的域是其节点与节点选择器匹配的域。 - 指定的 `minDomains` 的值必须大于 0。 - 当符合条件的、拓扑键匹配的域的数量小于 `minDomains` 时,Pod 拓扑分布将“全局最小值” (global minimum)设为 0,然后进行 `skew` 计算。“全局最小值”是一个符合条件的域中匹配 Pod 的最小数量,如果符合条件的域的数量小于 `minDomains`,则全局最小值为零。 - 当符合条件的拓扑键匹配域的个数等于或大于 `minDomains` 时,该值对调度没有影响。 - 当 `minDomains` 为 nil 时,约束的行为等于 `minDomains` 为 1。 - 当 `minDomains` 不为 nil 时,`whenUnsatisfiable` 的值必须为 \"`DoNotSchedule`\" 。 {{< note >}} `minDomains` 字段是在 1.24 版本中新增的 alpha 字段。你必须启用 `MinDomainsInPodToplogySpread` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)才能使用它。 {{< /note >}} - **topologyKey** 是节点标签的键。如果两个节点使用此键标记并且具有相同的标签值, 则调度器会将这两个节点视为处于同一拓扑域中。调度器试图在每个拓扑域中放置数量均衡的 Pod。 - **whenUnsatisfiable** 指示如果 Pod 不满足分布约束时如何处理: - `DoNotSchedule`(默认)告诉调度器不要调度。 - `ScheduleAnyway` 告诉调度器仍然继续调度,只是根据如何能将偏差最小化来对节点进行排序。 - **labelSelector** 用于查找匹配的 Pod。匹配此标签的 Pod 将被统计, 以确定相应拓扑域中 Pod 的数量。 有关详细信息,请参考[标签选择算符](/zh-cn/docs/concepts/overview/working-with-objects/labels/#label-selectors)。 当 Pod 定义了不止一个 `topologySpreadConstraint`,这些约束之间是逻辑与的关系。 kube-scheduler 会为新的 Pod 寻找一个能够满足所有约束的节点。 你可以执行 `kubectl explain Pod.spec.topologySpreadConstraints` 命令以了解关于 topologySpreadConstraints 的更多信息。 ### 例子:单个 TopologySpreadConstraint 假设你拥有一个 4 节点集群,其中标记为 `foo:bar` 的 3 个 Pod 分别位于 node1、node2 和 node3 中: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class zoneA,zoneB cluster; {{< /mermaid >}} 如果希望新来的 Pod 均匀分布在现有的可用区域,则可以按如下设置其规约: {{< codenew file=\"pods/topology-spread-constraints/one-constraint.yaml\" >}} `topologyKey: zone` 意味着均匀分布将只应用于存在标签键值对为 \"zone:<任何值>\" 的节点。 `whenUnsatisfiable: DoNotSchedule` 告诉调度器如果新的 Pod 不满足约束, 则让它保持悬决状态。 如果调度器将新的 Pod 放入 \"zoneA\",Pods 分布将变为 [3, 1],因此实际的偏差为 2(3 - 1)。这违反了 `maxSkew: 1` 的约定。此示例中,新 Pod 只能放置在 \"zoneB\" 上: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) p4(mypod) --> n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} 或者 {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) p4(mypod) --> n3 n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} 你可以调整 Pod 规约以满足各种要求: - 将 `maxSkew` 更改为更大的值,比如 \"2\",这样新的 Pod 也可以放在 \"zoneA\" 上。 - 将 `topologyKey` 更改为 \"node\",以便将 Pod 均匀分布在节点上而不是区域中。 在上面的例子中,如果 `maxSkew` 保持为 \"1\",那么传入的 Pod 只能放在 \"node4\" 上。 - 将 `whenUnsatisfiable: DoNotSchedule` 更改为 `whenUnsatisfiable: ScheduleAnyway`, 以确保新的 Pod 始终可以被调度(假设满足其他的调度 API)。 但是,最好将其放置在匹配 Pod 数量较少的拓扑域中。 (请注意,这一优先判定会与其他内部调度优先级(如资源使用率等)排序准则一起进行标准化。) ### 例子:多个 TopologySpreadConstraints 下面的例子建立在前面例子的基础上。假设你拥有一个 4 节点集群,其中 3 个标记为 `foo:bar` 的 Pod 分别位于 node1、node2 和 node3 上: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} 可以使用 2 个 TopologySpreadConstraint 来控制 Pod 在 区域和节点两个维度上的分布: {{< codenew file=\"pods/topology-spread-constraints/two-constraints.yaml\" >}} 在这种情况下,为了匹配第一个约束,新的 Pod 只能放置在 \"zoneB\" 中;而在第二个约束中, 新的 Pod 只能放置在 \"node4\" 上。最后两个约束的结果加在一起,唯一可行的选择是放置在 \"node4\" 上。 多个约束之间可能存在冲突。假设有一个跨越 2 个区域的 3 节点集群: {{}} graph BT subgraph \"zoneB\" p4(Pod) --> n3(Node3) p5(Pod) --> n3 end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n1 p3(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3,p4,p5 k8s; class zoneA,zoneB cluster; {{< /mermaid >}} 如果对集群应用 \"two-constraints.yaml\",会发现 \"mypod\" 处于 `Pending` 状态。 这是因为:为了满足第一个约束,\"mypod\" 只能放在 \"zoneB\" 中,而第二个约束要求 \"mypod\" 只能放在 \"node2\" 上。Pod 调度无法满足两种约束。 为了克服这种情况,你可以增加 `maxSkew` 或修改其中一个约束,让其使用 `whenUnsatisfiable: ScheduleAnyway`。 ### 节点亲和性与节点选择器的相互作用 {#interaction-with-node-affinity-and-node-selectors} 如果 Pod 定义了 `spec.nodeSelector` 或 `spec.affinity.nodeAffinity`, 调度器将在偏差计算中跳过不匹配的节点。 ### 示例:TopologySpreadConstraints 与 NodeAffinity 假设你有一个跨越 zoneA 到 zoneC 的 5 节点集群: {{}} graph BT subgraph \"zoneB\" p3(Pod) --> n3(Node3) n4(Node4) end subgraph \"zoneA\" p1(Pod) --> n1(Node1) p2(Pod) --> n2(Node2) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n1,n2,n3,n4,p1,p2,p3 k8s; class p4 plain; class zoneA,zoneB cluster; {{< /mermaid >}} {{}} graph BT subgraph \"zoneC\" n5(Node5) end classDef plain fill:#ddd,stroke:#fff,stroke-width:4px,color:#000; classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; classDef cluster fill:#fff,stroke:#bbb,stroke-width:2px,color:#326ce5; class n5 k8s; class zoneC cluster; {{< /mermaid >}} 而且你知道 \"zoneC\" 必须被排除在外。在这种情况下,可以按如下方式编写 YAML, 以便将 \"mypod\" 放置在 \"zoneB\" 上,而不是 \"zoneC\" 上。同样,`spec.nodeSelector` 也要一样处理。 {{< codenew file=\"pods/topology-spread-constraints/one-constraint-with-nodeaffinity.yaml\" >}} 调度器不会预先知道集群拥有的所有区域和其他拓扑域。拓扑域由集群中存在的节点确定。 在自动伸缩的集群中,如果一个节点池(或节点组)的节点数量为零, 而用户正期望其扩容时,可能会导致调度出现问题。 因为在这种情况下,调度器不会考虑这些拓扑域信息,因为它们是空的,没有节点。 ### 其他值得注意的语义 {#other-noticeable-semantics} 这里有一些值得注意的隐式约定: - 只有与新的 Pod 具有相同命名空间的 Pod 才能作为匹配候选者。 - 调度器会忽略没有 `topologySpreadConstraints[*].topologyKey` 的节点。这意味着: 1. 位于这些节点上的 Pod 不影响 `maxSkew` 的计算。 在上面的例子中,假设 \"node1\" 没有标签 \"zone\",那么 2 个 Pod 将被忽略, 因此传入的 Pod 将被调度到 \"zoneA\" 中。 2. 新的 Pod 没有机会被调度到这类节点上。 在上面的例子中,假设一个带有标签 `{zone-typo: zoneC}` 的 \"node5\" 加入到集群, 它将由于没有标签键 \"zone\" 而被忽略。 - 注意,如果新 Pod 的 `topologySpreadConstraints[*].labelSelector` 与自身的标签不匹配,将会发生什么。 在上面的例子中,如果移除新 Pod 上的标签,Pod 仍然可以调度到 \"zoneB\",因为约束仍然满足。 然而,在调度之后,集群的不平衡程度保持不变。zoneA 仍然有 2 个带有 {foo:bar} 标签的 Pod, zoneB 有 1 个带有 {foo:bar} 标签的 Pod。 因此,如果这不是你所期望的,建议工作负载的 `topologySpreadConstraints[*].labelSelector` 与其自身的标签匹配。 ### 集群级别的默认约束 {#cluster-level-default-constraints} 为集群设置默认的拓扑分布约束也是可能的。 默认拓扑分布约束在且仅在以下条件满足时才会被应用到 Pod 上: - Pod 没有在其 `.spec.topologySpreadConstraints` 设置任何约束; - Pod 隶属于某个服务、副本控制器、ReplicaSet 或 StatefulSet。 你可以在 [调度方案(Scheduling Profile)](/zh-cn/docs/reference/scheduling/config/#profiles) 中将默认约束作为 `PodTopologySpread` 插件参数的一部分来设置。 约束的设置采用[如前所述的 API](#api),只是 `labelSelector` 必须为空。 选择算符是根据 Pod 所属的服务、副本控制器、ReplicaSet 或 StatefulSet 来设置的。 配置的示例可能看起来像下面这个样子: ```yaml apiVersion: kubescheduler.config.k8s.io/v1beta3 kind: KubeSchedulerConfiguration profiles: - schedulerName: default-scheduler pluginConfig: - name: PodTopologySpread args: defaultConstraints: - maxSkew: 1 topologyKey: topology.kubernetes.io/zone whenUnsatisfiable: ScheduleAnyway defaultingType: List ``` {{< note >}} [`SelectorSpread` 插件](/zh-cn/docs/reference/scheduling/config/#scheduling-plugins)默认是被禁用的。 建议使用 `PodTopologySpread` 来实现类似的行为。 {{< /note >}} #### 内部默认约束 {#internal-default-constraints} {{< feature-state for_k8s_version=\"v1.24\" state=\"stable\" >}} 如果你没有为 Pod 拓扑分布配置任何集群级别的默认约束, kube-scheduler 的行为就像你指定了以下默认拓扑约束一样: ```yaml defaultConstraints: - maxSkew: 3 topologyKey: \"kubernetes.io/hostname\" whenUnsatisfiable: ScheduleAnyway - maxSkew: 5 topologyKey: \"topology.kubernetes.io/zone\" whenUnsatisfiable: ScheduleAnyway ``` 此外,原来用于提供等同行为的 `SelectorSpread` 插件默认被禁用。 {{< note >}} 对于分布约束中所指定的拓扑键而言,`PodTopologySpread` 插件不会为不包含这些主键的节点评分。 这可能导致在使用默认拓扑约束时,其行为与原来的 `SelectorSpread` 插件的默认行为不同, 如果你的节点不会 **同时** 设置 `kubernetes.io/hostname` 和 `topology.kubernetes.io/zone` 标签,你应该定义自己的约束而不是使用 Kubernetes 的默认约束。 {{< /note >}} 如果你不想为集群使用默认的 Pod 分布约束,你可以通过设置 `defaultingType` 参数为 `List` 并将 `PodTopologySpread` 插件配置中的 `defaultConstraints` 参数置空来禁用默认 Pod 分布约束。 ```yaml apiVersion: kubescheduler.config.k8s.io/v1beta3 kind: KubeSchedulerConfiguration profiles: - schedulerName: default-scheduler pluginConfig: - name: PodTopologySpread args: defaultConstraints: [] defaultingType: List ``` ## 与 PodAffinity/PodAntiAffinity 相比较 在 Kubernetes 中,与“亲和性”相关的指令控制 Pod 的调度方式(更密集或更分散)。 - 对于 `PodAffinity`,你可以尝试将任意数量的 Pod 集中到符合条件的拓扑域中。 - 对于 `PodAntiAffinity`,只能将一个 Pod 调度到某个拓扑域中。 要实现更细粒度的控制,你可以设置拓扑分布约束来将 Pod 分布到不同的拓扑域下, 从而实现高可用性或节省成本。这也有助于工作负载的滚动更新和平稳地扩展副本规模。 有关详细信息,请参考 [动机](https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/20190221-pod-topology-spread.md#motivation)文档。 ## 已知局限性 - 当 Pod 被移除时,无法保证约束仍被满足。例如,缩减某 Deployment 的规模时, Pod 的分布可能不再均衡。 你可以使用 [Descheduler](https://github.com/kubernetes-sigs/descheduler) 来重新实现 Pod 分布的均衡。 - 具有污点的节点上匹配的 Pods 也会被统计。 参考 [Issue 80921](https://github.com/kubernetes/kubernetes/issues/80921)。 ## {{% heading \"whatsnext\" %}} - [博客: PodTopologySpread介绍](https://kubernetes.io/blog/2020/05/introducing-podtopologyspread/) 详细解释了 `maxSkew`,并给出了一些高级的使用示例。 "} {"_id":"q-en-website-3c47b16bfd45e1c4407a4bcec606c6c8ddb51cb2aa6d8940648b92e135e0af16","text":" „--- --- title: I componenti di Kubernetes content_type: concept weight: 20"} {"_id":"q-en-website-3c4ee72794137b585d201e4b134ba0cf78b4f8f80841220c5f9c01e5a5be5c1c","text":"Initコンテナの順序と実行を考えるとき、リソースの使用に関して下記のルールが適用されます。 * 全てのInitコンテナの中で定義された最も高いリソースリクエストとリソースリミットが、*有効なinitリクエスト/リミット* になります。 * 全てのInitコンテナの中で定義された最も高いリソースリクエストとリソースリミットが、*有効なinitリクエスト/リミット* になります。いずれかのリソースでリミットが設定されていない場合、これが最上級のリミットとみなされます。 * Podのリソースの*有効なリクエスト/リミット* は、下記の2つの中のどちらか高い方となります。 * リソースに対する全てのアプリケーションコンテナのリクエスト/リミットの合計 * リソースに対する有効なinitリクエスト/リミット"} {"_id":"q-en-website-3d616ae2ce953284a60f6524a350b7c3629fbb4d7613247f594135cc5d4aabf9","text":"object named `default` for every namespace in your cluster. The `default` service accounts in each namespace get no permissions by default other than the [default API discovery permissions](/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings) that Kubernetes grants to all authenticated principals if role-based access control (RBAC) is enabled. If you delete the `default` ServiceAccount object in a namespace, the {{}} that Kubernetes grants to all authenticated principals if role-based access control (RBAC) is enabled. If you delete the `default` ServiceAccount object in a namespace, the {{< glossary_tooltip text=\"control plane\" term_id=\"control-plane\" >}} replaces it with a new one. If you deploy a Pod in a namespace, and you don't"} {"_id":"q-en-website-3e822568e9a8e83b3749f53ad9b4093deaa78dedc2291d0644cff066f359f4e9","text":" --- reviewers: - rickypai - thockin title: Adding entries to Pod /etc/hosts with HostAliases content_type: concept weight: 60 min-kubernetes-server-version: 1.7 --- Adding entries to a Pod's `/etc/hosts` file provides Pod-level override of hostname resolution when DNS and other options are not applicable. You can add these custom entries with the HostAliases field in PodSpec. Modification not using HostAliases is not suggested because the file is managed by the kubelet and can be overwritten on during Pod creation/restart. ## Default hosts file content Start an Nginx Pod which is assigned a Pod IP: ```shell kubectl run nginx --image nginx ``` ``` pod/nginx created ``` Examine a Pod IP: ```shell kubectl get pods --output=wide ``` ``` NAME READY STATUS RESTARTS AGE IP NODE nginx 1/1 Running 0 13s 10.200.0.4 worker0 ``` The hosts file content would look like this: ```shell kubectl exec nginx -- cat /etc/hosts ``` ``` # Kubernetes-managed hosts file. 127.0.0.1\tlocalhost ::1\tlocalhost ip6-localhost ip6-loopback fe00::0\tip6-localnet fe00::0\tip6-mcastprefix fe00::1\tip6-allnodes fe00::2\tip6-allrouters 10.200.0.4\tnginx ``` By default, the `hosts` file only includes IPv4 and IPv6 boilerplates like `localhost` and its own hostname. ## Adding additional entries with hostAliases In addition to the default boilerplate, you can add additional entries to the `hosts` file. For example: to resolve `foo.local`, `bar.local` to `127.0.0.1` and `foo.remote`, `bar.remote` to `10.1.2.3`, you can configure HostAliases for a Pod under `.spec.hostAliases`: {{< codenew file=\"service/networking/hostaliases-pod.yaml\" >}} You can start a Pod with that configuration by running: ```shell kubectl apply -f https://k8s.io/examples/service/networking/hostaliases-pod.yaml ``` ``` pod/hostaliases-pod created ``` Examine a Pod's details to see its IPv4 address and its status: ```shell kubectl get pod --output=wide ``` ``` NAME READY STATUS RESTARTS AGE IP NODE hostaliases-pod 0/1 Completed 0 6s 10.200.0.5 worker0 ``` The `hosts` file content looks like this: ```shell kubectl logs hostaliases-pod ``` ``` # Kubernetes-managed hosts file. 127.0.0.1\tlocalhost ::1\tlocalhost ip6-localhost ip6-loopback fe00::0\tip6-localnet fe00::0\tip6-mcastprefix fe00::1\tip6-allnodes fe00::2\tip6-allrouters 10.200.0.5\thostaliases-pod # Entries added by HostAliases. 127.0.0.1\tfoo.local\tbar.local 10.1.2.3\tfoo.remote\tbar.remote ``` with the additional entries specified at the bottom. ## Why does the kubelet manage the hosts file? {#why-does-kubelet-manage-the-hosts-file} The kubelet [manages](https://github.com/kubernetes/kubernetes/issues/14633) the `hosts` file for each container of the Pod to prevent Docker from [modifying](https://github.com/moby/moby/issues/17190) the file after the containers have already been started. {{< caution >}} Avoid making manual changes to the hosts file inside a container. If you make manual changes to the hosts file, those changes are lost when the container exits. {{< /caution >}} "} {"_id":"q-en-website-3f21ae3973e6d21ea34e3bf86052b2e94cabd01ce29db48b79f306b5acc3772d","text":" userInfo [Required]
authentication/v1.UserInfo authentication/v1.UserInfo

UserInfo is information about the requesting user

"} {"_id":"q-en-website-3fcd630daea04592ed39c0c549fd6fd5ec138b82b2a1f8b5f5f01a9cb37a12d9","text":" KubernetesのSecretはパスワード、OAuthトークン、SSHキーのような機密情報を保存し、管理できるようにします。 Secretに機密情報を保存することは、それらを{{< glossary_tooltip text=\"Pod\" term_id=\"pod\" >}}の定義や{{< glossary_tooltip text=\"コンテナイメージ\" term_id=\"image\" >}}に直接記載するより、安全で柔軟です。 詳しくは[Secretの設計文書](https://git.k8s.io/community/contributors/design-proposals/auth/secrets.md)を参照してください。 Secretはパスワード、トークン、キーのような小容量の機密データを含むオブジェクトです。 他の方法としては、そのような情報はPodの定義やイメージに含めることができます。 ユーザーはSecretを作ることができ、またシステムが作るSecretもあります。 Secretとは、パスワードやトークン、キーなどの少量の機密データを含むオブジェクトのことです。 このような情報は、Secretを用いないと{{< glossary_tooltip term_id=\"pod\" >}}の定義や{{< glossary_tooltip text=\"コンテナイメージ\" term_id=\"image\" >}}に直接記載することになってしまうかもしれません。 Secretを使用すれば、アプリケーションコードに機密データを含める必要がなくなります。 なぜなら、Secretは、それを使用するPodとは独立して作成することができ、 Podの作成、閲覧、編集といったワークフローの中でSecret(およびそのデータ)が漏洩する危険性が低くなるためです。 また、Kubernetesやクラスター内で動作するアプリケーションは、不揮発性ストレージに機密データを書き込まないようにするなど、Secretで追加の予防措置を取ることができます。 Secretsは、{{< glossary_tooltip text=\"ConfigMaps\" term_id=\"configmap\" >}}に似ていますが、機密データを保持するために用います。 {{< caution >}} KubernetesのSecretは、デフォルトでは、APIサーバーの基礎となるデータストア(etcd)に暗号化されずに保存されます。APIにアクセスできる人は誰でもSecretを取得または変更でき、etcdにアクセスできる人も同様です。 さらに、名前空間でPodを作成する権限を持つ人は、そのアクセスを使用して、その名前空間のあらゆるSecretを読むことができます。これには、Deploymentを作成する能力などの間接的なアクセスも含まれます。 Secretsを安全に使用するには、以下の手順を推奨します。 1. Secretsを[安全に暗号化する](/docs/tasks/administer-cluster/encrypt-data/) 2. Secretsのデータの読み取りを制限する[RBACルール](/docs/reference/access-authn-authz/authorization/)の有効化または設定 3. 適切な場合には、RBACなどのメカニズムを使用して、どの原則が新しいSecretの作成や既存のSecretの置き換えを許可されるかを制限します。 {{< /caution >}} "} {"_id":"q-en-website-40e0c1ee42717b2deca8662aa195e5cf3dabcb13c5d1b71df4f36c8aa81bfd84","text":"| `ProbeTerminationGracePeriod` | `false` | Alpha | 1.21 | | | `ProcMountType` | `false` | Alpha | 1.12 | | | `QOSReserved` | `false` | Alpha | 1.11 | | | `RemainingItemCount` | `false` | Alpha | 1.15 | | | `RemainingItemCount` | `false` | Alpha | 1.15 | 1.15 | | `RemainingItemCount` | `true` | Beta | 1.16 | | | `RemoveSelfLink` | `false` | Alpha | 1.16 | 1.19 | | `RemoveSelfLink` | `true` | Beta | 1.20 | | | `RotateKubeletServerCertificate` | `false` | Alpha | 1.7 | 1.11 |"} {"_id":"q-en-website-4150a9f64638a4fa97a488c5d32ed35107ebc6a821f9912a00cabd3401b3afe3","text":" --- title: Conceitos main_menu: true content_type: concept weight: 40 --- A seção de Conceitos irá te ajudar a aprender mais sobre as partes do ecossistema Kubernetes e as abstrações que o Kubernetes usa para representar seu {{< glossary_tooltip text=\"cluster\" term_id=\"cluster\" length=\"all\" >}}. Ela irá lhe ajudar a obter um entendimento mais profundo sobre como o Kubernetes funciona. "} {"_id":"q-en-website-41e441254509f93a77abc94d8cdbaf62af126c9345e2b6e658f8500c30152ed7","text":"{{- if or (eq .endTime nil ) (gt ( time .endTime ) now ) -}} {{- if not $announcementShown -}} {{- $announcementShown = true -}}