aws-node serviceaccount deleted with delete iamserviceaccount command
What were you trying to accomplish?
- When I tried to delete unnecessary serviceaccounts with
eksctl delete iamserviceaccount -f ... --only-missing --approve,kube-system/aws-nodewas deleted.
What happened?
kube-system/aws-nodehas been deleted and aws-node is no longer working withdisableIMDSv1 true, disablePodIMDS true.- Due to the change in https://github.com/weaveworks/eksctl/pull/2917,
kube-system/aws-nodeis created only when cluster is created, so after it is deleted, we have to use 0.34.0 to createkube-system/aws-node.
How to reproduce it?
I didn't add an option for disableIMDSv1 true, disablePodIMDS true because I'm keeping it simple in this log, but I can confirm that kube-system/aws-node has been deleted.
$ eksctl create cluster test-cluster --with-oidc --managed --spot
$ eksctl create iamserviceaccount -f sample-iam.yaml --approve
$ eksctl delete iamserviceaccount -f sample-iam.yaml --only-missing --approve
% cat sample-iam.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: test-cluster
region: ap-northeast-1
iam:
withOIDC: true
serviceAccounts:
- metadata:
name: s3-read-only
namespace: kube-system
attachPolicyARNs:
- "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess"
Logs
% eksctl create cluster test-cluster --with-oidc --managed --spot
[ℹ] eksctl version 0.36.2
[ℹ] 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
[ℹ] using Kubernetes version 1.18
[ℹ] creating EKS cluster "test-cluster" in "ap-northeast-1" region with managed nodes
[ℹ] will create 2 separate CloudFormation stacks for cluster itself and the initial managed nodegroup
[ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-1 --cluster=test-cluster'
[ℹ] CloudWatch logging will not be enabled for cluster "test-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=test-cluster'
[ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "test-cluster" in "ap-northeast-1"
[ℹ] 2 sequential tasks: { create cluster control plane "test-cluster", 3 sequential sub-tasks: { 3 sequential sub-tasks: { associate IAM OIDC provider, 2 sequential sub-tasks: { create IAM role for serviceaccount "kube-system/aws-node", create serviceaccount "kube-system/aws-node" }, restart daemonset "kube-system/aws-node" }, create addons, create managed nodegroup "ng-2dbd46a8" } }
[ℹ] building cluster stack "eksctl-test-cluster-cluster"
[ℹ] deploying stack "eksctl-test-cluster-cluster"
[ℹ] waiting for CloudFormation stack "eksctl-test-cluster-cluster"
[ℹ] waiting for CloudFormation stack "eksctl-test-cluster-cluster"
[ℹ] waiting for CloudFormation stack "eksctl-test-cluster-cluster"
.
.
[ℹ] waiting for CloudFormation stack "eksctl-test-cluster-nodegroup-ng-2dbd46a8"
[ℹ] waiting for the control plane availability...
[✔] saved kubeconfig as "/Users/..../.kube/config"
[ℹ] no tasks
[✔] all EKS cluster resources for "test-cluster" have been created
[ℹ] nodegroup "ng-2dbd46a8" has 2 node(s)
[ℹ] node "ip-192-168-81-167.ap-northeast-1.compute.internal" is ready
[ℹ] node "ip-192-168-85-137.ap-northeast-1.compute.internal" is ready
[ℹ] waiting for at least 2 node(s) to become ready in "ng-2dbd46a8"
[ℹ] nodegroup "ng-2dbd46a8" has 2 node(s)
[ℹ] node "ip-192-168-81-167.ap-northeast-1.compute.internal" is ready
[ℹ] node "ip-192-168-85-137.ap-northeast-1.compute.internal" is ready
[ℹ] kubectl command should work with "/Users/..../.kube/config", try 'kubectl get nodes'
[✔] EKS cluster "test-cluster" in "ap-northeast-1" region is ready
% eksctl create iamserviceaccount -f sample-iam.yaml --approve
[ℹ] eksctl version 0.36.2
[ℹ] using region ap-northeast-1
[ℹ] 1 existing iamserviceaccount(s) (kube-system/aws-node) will be excluded
[ℹ] 1 iamserviceaccount (kube-system/s3-read-only) was included (based on the include/exclude rules)
[!] serviceaccounts that exists in Kubernetes will be excluded, use --override-existing-serviceaccounts to override
[ℹ] 1 task: { 2 sequential sub-tasks: { create IAM role for serviceaccount "kube-system/s3-read-only", create serviceaccount "kube-system/s3-read-only" } }
[ℹ] building iamserviceaccount stack "eksctl-test-cluster-addon-iamserviceaccount-kube-system-s3-read-only"
[ℹ] deploying stack "eksctl-test-cluster-addon-iamserviceaccount-kube-system-s3-read-only"
[ℹ] waiting for CloudFormation stack "eksctl-test-cluster-addon-iamserviceaccount-kube-system-s3-read-only"
[ℹ] created serviceaccount "kube-system/s3-read-only"
% eksctl delete iamserviceaccount -f sample-iam.yaml --only-missing --approve
[ℹ] eksctl version 0.36.2
[ℹ] using region ap-northeast-1
[ℹ] comparing 1 iamserviceaccounts defined in the given config ("sample-iam.yaml") against remote state
[ℹ] iamserviceaccounts "kube-system/s3-read-only" present in the given config and the cluster
[ℹ] iamserviceaccounts "kube-system/aws-node" present in the cluster, but missing from the given config
[ℹ] 1 iamserviceaccount (kube-system/aws-node) was included (based on the include/exclude rules)
[ℹ] 1 iamserviceaccount (kube-system/s3-read-only) was excluded (based on the include/exclude rules)
[ℹ] 1 task: { 2 sequential sub-tasks: { delete IAM role for serviceaccount "kube-system/aws-node" [async], delete serviceaccount "kube-system/aws-node" } }
[ℹ] will delete stack "eksctl-test-cluster-addon-iamserviceaccount-kube-system-aws-node"
[ℹ] deleted serviceaccount "kube-system/aws-node"
Anything else we need to know?
Versions
$ eksctl version
0.36.2
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.9", GitCommit:"94f372e501c973a7fa9eb40ec9ebd2fe7ca69848", GitTreeState:"clean", BuildDate:"2020-09-16T13:56:40Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.9-eks-d1db3c", GitCommit:"d1db3c46e55f95d6a7d3e5578689371318f95ff9", GitTreeState:"clean", BuildDate:"2020-10-20T22:18:07Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
@cw-sakamoto You should be able to use create iamserviceaccount to create aws-node by just specifying it in the config as a workaround. I suspect this has to do with --only-missing.
@michaelbeaumont Thanks for your comments.
just specifying it in the config as a workaround. I suspect this has to do with --only-missing.
I have confirmed that it not be removed by listing it in a file with --only-missing.