Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
EKS Fargate-Unterstützung
AWS Fargate
Amazon EKS kann jetzt Pods auf AWS Fargate starten. Dadurch müssen Sie sich keine Gedanken darüber machen, wie Sie die Infrastruktur für Pods bereitstellen oder verwalten, und es wird einfacher, leistungsstarke, hochverfügbare Kubernetes-Anwendungen auf AWS zu erstellen und auszuführen.
Einen Cluster mit Fargate-Unterstützung erstellen
Sie können einen Cluster mit Fargate-Unterstützung hinzufügen mit:
eksctl create cluster --fargate [ℹ] eksctl version 0.11.0 [ℹ] using region ap-northeast-1 [ℹ] setting availability zones to [ap-northeast-1a ap-northeast-1d ap-northeast-1c] [ℹ] subnets for ap-northeast-1a - public:192.168.0.0/19 private:192.168.96.0/19 [ℹ] subnets for ap-northeast-1d - public:192.168.32.0/19 private:192.168.128.0/19 [ℹ] subnets for ap-northeast-1c - public:192.168.64.0/19 private:192.168.160.0/19 [ℹ] nodegroup "ng-dba9d731" will use "ami-02e124a380df41614" [AmazonLinux2/1.14] [ℹ] using Kubernetes version 1.14 [ℹ] creating EKS cluster "ridiculous-painting-1574859263" in "ap-northeast-1" region [ℹ] will create 2 separate CloudFormation stacks for cluster itself and the initial nodegroup [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-1 --cluster=ridiculous-painting-1574859263' [ℹ] CloudWatch logging will not be enabled for cluster "ridiculous-painting-1574859263" in "ap-northeast-1" [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=ap-northeast-1 --cluster=ridiculous-painting-1574859263' [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "ridiculous-painting-1574859263" in "ap-northeast-1" [ℹ] 2 sequential tasks: { create cluster control plane "ridiculous-painting-1574859263", create nodegroup "ng-dba9d731" } [ℹ] building cluster stack "eksctl-ridiculous-painting-1574859263-cluster" [ℹ] deploying stack "eksctl-ridiculous-painting-1574859263-cluster" [ℹ] building nodegroup stack "eksctl-ridiculous-painting-1574859263-nodegroup-ng-dba9d731" [ℹ] --nodes-min=2 was set automatically for nodegroup ng-dba9d731 [ℹ] --nodes-max=2 was set automatically for nodegroup ng-dba9d731 [ℹ] deploying stack "eksctl-ridiculous-painting-1574859263-nodegroup-ng-dba9d731" [✔] all EKS cluster resources for "ridiculous-painting-1574859263" have been created [✔] saved kubeconfig as "/Users/marc/.kube/config" [ℹ] adding identity "arn:aws:iam::123456789012:role/eksctl-ridiculous-painting-157485-NodeInstanceRole-104DXUJOFDPO5" to auth ConfigMap [ℹ] nodegroup "ng-dba9d731" has 0 node(s) [ℹ] waiting for at least 2 node(s) to become ready in "ng-dba9d731" [ℹ] nodegroup "ng-dba9d731" has 2 node(s) [ℹ] node "ip-192-168-27-156.ap-northeast-1.compute.internal" is ready [ℹ] node "ip-192-168-95-177.ap-northeast-1.compute.internal" is ready [ℹ] creating Fargate profile "default" on EKS cluster "ridiculous-painting-1574859263" [ℹ] created Fargate profile "default" on EKS cluster "ridiculous-painting-1574859263" [ℹ] kubectl command should work with "/Users/marc/.kube/config", try 'kubectl get nodes' [✔] EKS cluster "ridiculous-painting-1574859263" in "ap-northeast-1" region is ready
Dieser Befehl hat einen Cluster und ein Fargate-Profil erstellt. Dieses Profil enthält bestimmte Informationen, die AWS benötigt, um Pods in Fargate zu instanziieren. Dies sind:
-
Pod-Ausführungsrolle, um die für die Ausführung des Pods erforderlichen Berechtigungen und den Netzwerkstandort (Subnetz) für die Ausführung des Pods zu definieren. Dadurch können dieselben Netzwerk- und Sicherheitsberechtigungen auf mehrere Fargate-Pods angewendet werden, und es wird einfacher, vorhandene Pods auf einem Cluster zu Fargate zu migrieren.
-
Selektor, um zu definieren, welche Pods auf Fargate laufen sollen. Dieser besteht aus einem
namespace
und.labels
Wenn das Profil nicht angegeben ist, aber die Unterstützung für Fargate aktiviert ist und --fargate
ein Fargate-Standardprofil erstellt wird. Dieses Profil zielt auf die default
und die kube-system
Namespaces ab, sodass Pods in diesen Namespaces auf Fargate laufen.
Das erstellte Fargate-Profil kann mit dem folgenden Befehl überprüft werden:
eksctl get fargateprofile --cluster ridiculous-painting-1574859263 -o yaml - name: fp-default podExecutionRoleARN: arn:aws:iam::123456789012:role/eksctl-ridiculous-painting-1574859263-ServiceRole-EIFQOH0S1GE7 selectors: - namespace: default - namespace: kube-system subnets: - subnet-0b3a5522f3b48a742 - subnet-0c35f1497067363f3 - subnet-0a29aa00b25082021
Weitere Informationen zu Selektoren finden Sie unter Entwerfen von Fargate-Profilen.
Erstellen eines Clusters mit Fargate-Unterstützung mithilfe einer Konfigurationsdatei
Die folgende Konfigurationsdatei deklariert einen EKS-Cluster mit einer Knotengruppe, die aus einer EC2 m5.large
Instanz und zwei Fargate-Profilen besteht. Alle in den kube-system
Namespaces default
und definierten Pods werden auf Fargate ausgeführt. Alle Pods im dev
Namespace, die auch das Label haben, dev=passed
laufen auch auf Fargate. Alle anderen Pods werden auf dem Knoten in geplant. ng-1
# An example of ClusterConfig with a normal nodegroup and a Fargate profile. --- apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: fargate-cluster region: ap-northeast-1 nodeGroups: - name: ng-1 instanceType: m5.large desiredCapacity: 1 fargateProfiles: - name: fp-default selectors: # All workloads in the "default" Kubernetes namespace will be # scheduled onto Fargate: - namespace: default # All workloads in the "kube-system" Kubernetes namespace will be # scheduled onto Fargate: - namespace: kube-system - name: fp-dev selectors: # All workloads in the "dev" Kubernetes namespace matching the following # label selectors will be scheduled onto Fargate: - namespace: dev labels: env: dev checks: passed
eksctl create cluster -f cluster-fargate.yaml [ℹ] eksctl version 0.11.0 [ℹ] using region ap-northeast-1 [ℹ] setting availability zones to [ap-northeast-1c ap-northeast-1a ap-northeast-1d] [ℹ] subnets for ap-northeast-1c - public:192.168.0.0/19 private:192.168.96.0/19 [ℹ] subnets for ap-northeast-1a - public:192.168.32.0/19 private:192.168.128.0/19 [ℹ] subnets for ap-northeast-1d - public:192.168.64.0/19 private:192.168.160.0/19 [ℹ] nodegroup "ng-1" will use "ami-02e124a380df41614" [AmazonLinux2/1.14] [ℹ] using Kubernetes version 1.14 [ℹ] creating EKS cluster "fargate-cluster" in "ap-northeast-1" region with Fargate profile and un-managed nodes [ℹ] 1 nodegroup (ng-1) was included (based on the include/exclude rules) [ℹ] will create a CloudFormation stack for cluster itself and 1 nodegroup stack(s) [ℹ] will create a CloudFormation stack for cluster itself and 0 managed nodegroup stack(s) [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-1 --cluster=fargate-cluster' [ℹ] CloudWatch logging will not be enabled for cluster "fargate-cluster" in "ap-northeast-1" [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=ap-northeast-1 --cluster=fargate-cluster' [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "fargate-cluster" in "ap-northeast-1" [ℹ] 2 sequential tasks: { create cluster control plane "fargate-cluster", create nodegroup "ng-1" } [ℹ] building cluster stack "eksctl-fargate-cluster-cluster" [ℹ] deploying stack "eksctl-fargate-cluster-cluster" [ℹ] building nodegroup stack "eksctl-fargate-cluster-nodegroup-ng-1" [ℹ] --nodes-min=1 was set automatically for nodegroup ng-1 [ℹ] --nodes-max=1 was set automatically for nodegroup ng-1 [ℹ] deploying stack "eksctl-fargate-cluster-nodegroup-ng-1" [✔] all EKS cluster resources for "fargate-cluster" have been created [✔] saved kubeconfig as "/home/user1/.kube/config" [ℹ] adding identity "arn:aws:iam::123456789012:role/eksctl-fargate-cluster-nod-NodeInstanceRole-42Q80B2Z147I" to auth ConfigMap [ℹ] nodegroup "ng-1" has 0 node(s) [ℹ] waiting for at least 1 node(s) to become ready in "ng-1" [ℹ] nodegroup "ng-1" has 1 node(s) [ℹ] node "ip-192-168-71-83.ap-northeast-1.compute.internal" is ready [ℹ] creating Fargate profile "fp-default" on EKS cluster "fargate-cluster" [ℹ] created Fargate profile "fp-default" on EKS cluster "fargate-cluster" [ℹ] creating Fargate profile "fp-dev" on EKS cluster "fargate-cluster" [ℹ] created Fargate profile "fp-dev" on EKS cluster "fargate-cluster" [ℹ] "coredns" is now schedulable onto Fargate [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" pods are now scheduled onto Fargate [ℹ] kubectl command should work with "/home/user1/.kube/config", try 'kubectl get nodes' [✔] EKS cluster "fargate-cluster" in "ap-northeast-1" region is ready
Entwerfen von Fargate-Profilen
Jeder Selektoreintrag besteht aus bis zu zwei Komponenten, einem Namespace und einer Liste von Schlüssel-Wert-Paaren. Nur die Namespace-Komponente ist erforderlich, um einen Selektoreintrag zu erstellen. Alle Regeln (Namespaces, Schlüssel-Wert-Paare) müssen für einen Pod gelten, damit sie einem Selektoreintrag entsprechen. Ein Pod muss nur einem Selektoreintrag entsprechen, um auf dem Profil ausgeführt zu werden. Jeder Pod, der alle Bedingungen in einem Auswahlfeld erfüllt, würde für die Ausführung auf Fargate geplant. Alle Pods, die keinem der Namespaces auf der Whitelist entsprechen, bei denen der Benutzer jedoch manuell den Scheduler: Fargate-Scheduler eingegeben hat, würden im Status Ausstehend hängen bleiben, da sie nicht autorisiert waren, auf Fargate ausgeführt zu werden.
Profile müssen die folgenden Anforderungen erfüllen:
-
Pro Profil ist ein Selektor erforderlich
-
Jeder Selektor muss einen Namespace enthalten; Beschriftungen sind optional
Beispiel: Planung der Arbeitslast in Fargate
Um Pods auf Fargate für das oben erwähnte Beispiel zu planen, könnte man beispielsweise einen Namespace namens erstellen dev
und den Workload dort bereitstellen:
kubectl create namespace dev namespace/dev created kubectl run nginx --image=nginx --restart=Never --namespace dev pod/nginx created kubectl get pods --all-namespaces --output wide NAMESPACE NAME READY STATUS AGE IP NODE dev nginx 1/1 Running 75s 192.168.183.140 fargate-ip-192-168-183-140.ap-northeast-1.compute.internal kube-system aws-node-44qst 1/1 Running 21m 192.168.70.246 ip-192-168-70-246.ap-northeast-1.compute.internal kube-system aws-node-4vr66 1/1 Running 21m 192.168.23.122 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system coredns-699bb99bf8-84x74 1/1 Running 26m 192.168.2.95 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system coredns-699bb99bf8-f6x6n 1/1 Running 26m 192.168.90.73 ip-192-168-70-246.ap-northeast-1.compute.internal kube-system kube-proxy-brxhg 1/1 Running 21m 192.168.23.122 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system kube-proxy-zd7s8 1/1 Running 21m 192.168.70.246 ip-192-168-70-246.ap-northeast-1.compute.internal
Aus der Ausgabe des letzten kubectl get pods
Befehls können wir ersehen, dass der nginx
Pod in einem Knoten namens bereitgestellt wird. fargate-ip-192-168-183-140.ap-northeast-1.compute.internal
Verwaltung von Fargate-Profilen
Um Kubernetes-Workloads auf Fargate bereitzustellen, benötigt EKS ein Fargate-Profil. Kümmert sich beim Erstellen eines Clusters wie in den obigen Beispielen darum, eksctl
indem es ein Standardprofil erstellt. Bei einem bereits vorhandenen Cluster ist es auch möglich, ein Fargate-Profil mit dem eksctl create fargateprofile
folgenden Befehl zu erstellen:
Anmerkung
Dieser Vorgang wird nur auf Clustern unterstützt, die auf der EKS-Plattformversion eks.5
oder höher ausgeführt werden.
Anmerkung
Wenn das bestehende mit einer Version eksctl
vor 0.11.0 erstellt wurde, müssen Sie es ausführen, eksctl upgrade
cluster
bevor Sie das Fargate-Profil erstellen.
eksctl create fargateprofile --namespace dev --cluster fargate-example-cluster [ℹ] creating Fargate profile "fp-9bfc77ad" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-9bfc77ad" on EKS cluster "fargate-example-cluster"
Sie können auch den Namen des zu erstellenden Fargate-Profils angeben. Dieser Name darf nicht mit dem Präfix eks-
beginnen.
eksctl create fargateprofile --namespace dev --cluster fargate-example-cluster --name fp-development [ℹ] created Fargate profile "fp-development" on EKS cluster "fargate-example-cluster"
Wenn Sie diesen Befehl mit CLI-Flags verwenden, kann eksctl nur ein einzelnes Fargate-Profil mit einem einfachen Selektor erstellen. Für komplexere Selektoren, zum Beispiel mit mehr Namespaces, unterstützt eksctl die Verwendung einer Konfigurationsdatei:
apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: fargate-example-cluster region: ap-northeast-1 fargateProfiles: - name: fp-default selectors: # All workloads in the "default" Kubernetes namespace will be # scheduled onto Fargate: - namespace: default # All workloads in the "kube-system" Kubernetes namespace will be # scheduled onto Fargate: - namespace: kube-system - name: fp-dev selectors: # All workloads in the "dev" Kubernetes namespace matching the following # label selectors will be scheduled onto Fargate: - namespace: dev labels: env: dev checks: passed
eksctl create fargateprofile -f fargate-example-cluster.yaml [ℹ] creating Fargate profile "fp-default" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-default" on EKS cluster "fargate-example-cluster" [ℹ] creating Fargate profile "fp-dev" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-dev" on EKS cluster "fargate-example-cluster" [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" pods are now scheduled onto Fargate
Um bestehende Fargate-Profile in einem Cluster zu sehen:
eksctl get fargateprofile --cluster fargate-example-cluster NAME SELECTOR_NAMESPACE SELECTOR_LABELS POD_EXECUTION_ROLE_ARN SUBNETS fp-9bfc77ad dev <none> arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79 subnet-00adf1d8c99f83381,subnet-04affb163ffab17d4,subnet-035b34379d5ef5473
Und um sie im yaml
Format zu sehen:
eksctl get fargateprofile --cluster fargate-example-cluster -o yaml - name: fp-9bfc77ad podExecutionRoleARN: arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79 selectors: - namespace: dev subnets: - subnet-00adf1d8c99f83381 - subnet-04affb163ffab17d4 - subnet-035b34379d5ef5473
Oder im json
Format:
eksctl get fargateprofile --cluster fargate-example-cluster -o json [ { "name": "fp-9bfc77ad", "podExecutionRoleARN": "arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79", "selectors": [ { "namespace": "dev" } ], "subnets": [ "subnet-00adf1d8c99f83381", "subnet-04affb163ffab17d4", "subnet-035b34379d5ef5473" ] } ]
Fargate-Profile sind von Natur aus unveränderlich. Um etwas zu ändern, erstellen Sie ein neues Fargate-Profil mit den gewünschten Änderungen und löschen Sie das alte mit dem eksctl delete fargateprofile
Befehl wie im folgenden Beispiel:
eksctl delete fargateprofile --cluster fargate-example-cluster --name fp-9bfc77ad --wait 2019-11-27T19:04:26+09:00 [ℹ] deleting Fargate profile "fp-9bfc77ad" ClusterName: "fargate-example-cluster", FargateProfileName: "fp-9bfc77ad" }
Beachten Sie, dass das Löschen des Profils ein Vorgang ist, der bis zu einigen Minuten dauern kann. Wenn das --wait
Flag nicht angegeben ist, geht eksctl
optimistisch davon aus, dass das Profil gelöscht wird, und kehrt zurück, sobald die AWS-API-Anfrage gesendet wurde. Um zu eksctl
warten, bis das Profil erfolgreich gelöscht wurde, verwenden Sie --wait
es wie im obigen Beispiel.