kops: AWS iam node roles missing permissions for dockerconfig and addons

/kind bug

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

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. 1.26.3

3. What cloud provider are you using? AWS

4. What commands did you run? What is the simplest way to reproduce this issue? Kops upgrade to kubernetes version 1.26

5. What happened after the commands executed? I went to rotate the master nodes, however noticed that some of the control plane containers weren’t coming up due to 401. We use our own private container registry. I did some investigation and noticed the dockerconfig file was not getting populated on all the EC2 instances. I then worked out that the IAM roles were missing the required s3 permissions for these two locations:

/secrets/dockerconfig
/addons/*

As a temporary fix i have added the S3 permissions into the additionalPolicies section.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 16 (9 by maintainers)

Most upvoted comments

I just had a long (and somewhat frustrating) debugging episode that turned out to be caused by this issue.

This is on kOps 1.28.1 with AWS, Kubernetes 1.26.11, using Gossip DNS.

My problem was that regular nodes did not get a /root/.docker/config.json on first boot, despite having a dockerconfig secret. Control-plane nodes did however get them. Looking through the nodeup logs I see that it tried to read the secret:

nodeup[7896]: I1208 21:46:17.442071    7896 s3fs.go:371] Reading file "s3://<redacted>-kops-state/dev.k8s.local/secrets/dockerconfig"

As I saw no following error I assumed it had succeeded, but I also noticed that there was no File task in the logs for writing the secret to disk and chmoding it.

Looking through the source I see that s3fs read errors are actually swallowed by the VFSSecretStoreReader. First here:

https://github.com/kubernetes/kops/blob/2038e4c08fe6a1f768e607ed14988cc929bf52f9/upup/pkg/fi/secrets/vfs_secretstorereader.go#L76-L83

So the error is not returned unless it’s a 404 and the code will go on and try to JSON unmarshal 0 bytes. This will shadow the actual error with an unexpected end of JSON input error. But this error is in turn swallowed by the caller:

https://github.com/kubernetes/kops/blob/2038e4c08fe6a1f768e607ed14988cc929bf52f9/nodeup/pkg/model/secrets.go#L52

I patched nodeup with logging of the errors and restarted kops-configuration.service to see what was happening:

nodeup[7896]: I1208 21:46:17.449886    7896 s3fs.go:380] Read error: AccessDenied: Access Denied
nodeup[7896]:         status code: 403, request id: <redacted>, host id: <redacted>

Looking at the node IAM policy (nodes.dev.k8s.local) it was obvious that it had no access to the dockerconfig secret on s3://<redacted>-kops-state/dev.k8s.local/secrets/dockerconfig:

{
	"Statement": [
		{
			"Action": [
				"s3:Get*"
			],
			"Effect": "Allow",
			"Resource": [
				"arn:aws:s3:::<redacted>-kops-state/dev.k8s.local/cluster-completed.spec",
				"arn:aws:s3:::<redacted>-kops-state/dev.k8s.local/igconfig/node/*"
			]
		},
        …
}

Some questions:

  1. Does Gossip DNS mean no kops-controller bootstrapping and therefore no secrets from there?
  2. If so, and that means that dockerconfig is not supported with Gossip DNS, shouldn’t it be documented somewhere?
  3. Is the swallowing/shadowing of errors in nodeup intentional, or should I file a separate issue about it?

+1, this is a pretty significant breaking change, and it seems like it was a conscious decision to remove the feature gate to keep existing behavior.

Is there a documented alternative or some other way to restore the previous behavior?