Skip to content

aws-iam-authenticator daemonset unable to start due to host fs permissions #13616

@gregkoganvmm

Description

@gregkoganvmm

/kind bug

1. What kops version are you running? The command kops version, will display
this information.

1.23.0
2. What Kubernetes version are you running? kubectl version will print the
version if a cluster is running or provide the Kubernetes version specified as
a kops flag.

Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:51:05Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"darwin/arm64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:52:18Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"linux/arm64"}

3. What cloud provider are you using?
AWS
4. What commands did you run? What is the simplest way to reproduce this issue?
Follow this guide for an existing cluster:
https://kops.sigs.k8s.io/authentication/#aws-iam-authenticator
6. What did you expect to happen?
aws-iam-authenticator deamonset starts up successfully
7. Please provide your cluster manifest. Execute
kops get --name my.example.com -o yaml to display your cluster manifest.
You may want to remove your cluster name and other sensitive information.

....
 authentication:
    aws:
      image: 602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:v0.5.7-arm64
  authorization:
    rbac: {}

...

8. Please run the commands with most verbose logging by adding the -v 10 flag.
Paste the logs into this report, or in a gist and provide the gist link here.

time="2022-05-06T20:04:02Z" level=info msg="starting mapper \"MountedFile\""
time="2022-05-06T20:04:02Z" level=info msg="mapping IAM role" groups="[system:masters]" role="arn:aws:iam::xxx:role/ZZZZ" username=kubernetes-admin
time="2022-05-06T20:04:02Z" level=info msg="mapping IAM user" groups="[system:masters]" user="arn:aws:iam::xxx:user/greg.tinoco" username=YYY
time="2022-05-06T20:04:02Z" level=info msg="mapping IAM user" groups="[system:masters]" user="arn:aws:iam::xxx:user/gkogan" username=UUU
time="2022-05-06T20:04:02Z" level=info msg="mapping IAM Account" accountID=xxx
time="2022-05-06T20:04:02Z" level=fatal msg="could not load/generate a certificate" error="open /var/aws-iam-authenticator/cert.pem: permission denied"

9. Anything else do we need to know?
The code seems to be directly affected by the 600 permissions - it appears the 666 is what is needed to make aws-iam-authenticator happy

c.AddTask(&nodetasks.File{
Path: "/srv/kubernetes/aws-iam-authenticator/cert.pem",
Contents: certificate,
Type: nodetasks.FileType_File,
Mode: fi.String("600"),
Owner: fi.String("aws-iam-authenticator"),
Group: fi.String("aws-iam-authenticator"),
})
c.AddTask(&nodetasks.File{
Path: "/srv/kubernetes/aws-iam-authenticator/key.pem",
Contents: privateKey,
Type: nodetasks.FileType_File,
Mode: fi.String("600"),
Owner: fi.String("aws-iam-authenticator"),
Group: fi.String("aws-iam-authenticator"),
})
}

As soon as I manually set the 777 on the directory and 666 on the files inside `/var/aws-iam-authenticator/, the daemonset started working fine. There is really no reason why aws-iam-authenticator needs write access there that I can think of, but looks like it is required.

here's the daemonset def:

- name: aws-iam-authenticator
          image: >-
            602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:v0.5.7-arm64
          args:
            - server
            - '--config=/etc/aws-iam-authenticator/config.yaml'
            - '--state-dir=/var/aws-iam-authenticator'
            - '--kubeconfig-pregenerated=true'

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions