Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cluster-autoscaler): add missing permission #16853

Merged

Conversation

guilhermef
Copy link
Contributor

@guilhermef guilhermef commented Sep 22, 2024

While trying to create a new cluster with Kops, I noticed the following error:

I0922 19:58:53.909807       1 aws_wrapper.go:706] 0 launch configurations to query
I0922 19:58:53.909814       1 aws_wrapper.go:707] 0 launch templates to query
I0922 19:58:53.909822       1 aws_wrapper.go:727] Successfully queried 0 launch configurations
I0922 19:58:53.909830       1 aws_wrapper.go:738] Successfully queried 0 launch templates
E0922 19:58:53.965192       1 aws_wrapper.go:744] Failed to query instance requirements for ASG spot-arm64-us-east.case.k8s.local: UnauthorizedOperation: You are not authorized to perform this operation. User: arn:aws:sts::359113738869:assumed-role/cluster-autoscaler.kube-system.sa.case.k8s.local/1727035092386409452 is not authorized to perform: ec2:DescribeImages because no identity-based policy allows the ec2:DescribeImages action
status code: 403, request id: bb96e296-3fe3-4650-9b03-822707465041
I0922 19:58:53.965225       1 aws_wrapper.go:749] Successfully queried instance requirements for 1 ASGs 
E0922 19:58:53.965241       1 mixed_nodeinfos_processor.go:160] Unable to build proper template node for spot-arm64-us-east.case.k8s.local: could not find instance type for spot-arm64-us-east.case.k8s.local
E0922 19:58:53.965258       1 static_autoscaler.go:380] Failed to get node infos for groups: could not find instance type for spot-arm64-us-east.case.k8s.local

According to the recommend cluster-autoscale policy the actions ec2:DescribeImages and ec2:GetInstanceTypesFromInstanceRequirements are required.

kops version
Client version: 1.30.1

Cluster.yaml used during the creation

---
apiVersion: kops.k8s.io/v1alpha2
kind: Cluster
metadata:
  name: case.k8s.local
spec:
  api:
    loadBalancer:
      class: Network
      type: Public
  authorization:
    rbac: {}
  channel: stable
  cloudProvider: aws
  configBase: s3://case-kops-state/kops-state/case.k8s.local
  etcdClusters:
    - cpuRequest: 200m
      etcdMembers:
        - encryptedVolume: true
          instanceGroup: control-plane-us-east-1a
          name: a
        - encryptedVolume: true
          instanceGroup: control-plane-us-east-1b
          name: b
        - encryptedVolume: true
          instanceGroup: control-plane-us-east-1c
          name: c
      manager:
        backupRetentionDays: 90
      memoryRequest: 100Mi
      name: main
    - cpuRequest: 100m
      etcdMembers:
        - encryptedVolume: true
          instanceGroup: control-plane-us-east-1a
          name: a
        - encryptedVolume: true
          instanceGroup: control-plane-us-east-1b
          name: b
        - encryptedVolume: true
          instanceGroup: control-plane-us-east-1c
          name: c
      manager:
        backupRetentionDays: 90
      memoryRequest: 100Mi
      name: events
  iam:
    allowContainerRegistry: true
    legacy: false
    useServiceAccountExternalPermissions: true
  kubeProxy:
    enabled: false
  kubelet:
    anonymousAuth: false
  kubernetesApiAccess:
    - 0.0.0.0/0
    - ::/0
  kubernetesVersion: 1.30.2
  networkCIDR: 172.20.0.0/16
  networking:
    cilium:
      enableNodePort: true
  nonMasqueradeCIDR: 100.64.0.0/10
  serviceAccountIssuerDiscovery:
    discoveryStore: s3://case-discovery-store/discovery/case.k8s.local
    enableAWSOIDCProvider: true
  # sshAccess:
  #   - 0.0.0.0/0
  #   - ::/0
  # SSM Access doesn't need SSH ports to be open
  subnets:
    - name: us-east-1a
      type: Private
      zone: us-east-1a
    - name: us-east-1b
      type: Private
      zone: us-east-1b
    - name: us-east-1c
      type: Private
      zone: us-east-1c
    - name: utility-us-east-1a
      zone: us-east-1a
      type: Utility
    - name: utility-us-east-1b
      zone: us-east-1b
      type: Utility
    - name: utility-us-east-1c
      zone: us-east-1c
      type: Utility
  topology:
    masters: private
    nodes: private
    dns:
      type: None

  metricsServer:
    enabled: true

  clusterAutoscaler:
    enabled: true
    expander: least-waste
    awsUseStaticInstanceList: false

  externalPolicies:
    node:
      - arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetTaggingRole
      - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
  certManager:
    enabled: true
    defaultIssuer: CaseIssuer
---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: control-plane-us-east-1a
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id
  machineType: t3.medium
  maxSize: 1
  minSize: 1
  role: Master
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1a
---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: control-plane-us-east-1b
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id
  machineType: t3.medium
  maxSize: 1
  minSize: 1
  role: Master
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1b
---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: control-plane-us-east-1c
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id
  machineType: t3.medium
  maxSize: 1
  minSize: 1
  role: Master
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1c

---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: nodes-us-east-1a
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id
  machineType: t3.medium
  maxSize: 10
  minSize: 0
  role: Node
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1a

---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: nodes-us-east-1b
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id
  machineType: t3.medium
  maxSize: 10
  minSize: 0
  role: Node
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1b

---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: nodes-us-east-1c
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id
  machineType: t3.medium
  maxSize: 10
  minSize: 0
  role: Node
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1c

---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: spot-us-east
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/amd64/hvm/ebs-gp2/ami-id
  mixedInstancesPolicy:
    instanceRequirements:
      cpu:
        min: "2"
        max: "32"
      memory:
        min: "2G"
    onDemandAboveBase: 0
    onDemandBase: 0
    spotAllocationStrategy: capacity-optimized
  nodeLabels:
    kops.k8s.io/capacity: spot
  maxSize: 10
  minSize: 0
  role: Node
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1a
    - us-east-1b
    - us-east-1c

---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: case.k8s.local
  name: spot-arm64-us-east
spec:
  image: ssm:/aws/service/canonical/ubuntu/server/22.04/stable/current/arm64/hvm/ebs-gp2/ami-id
  mixedInstancesPolicy:
    instanceRequirements:
      cpu:
        min: "2"
        max: "32"
      memory:
        min: "2G"
    onDemandAboveBase: 0
    onDemandBase: 0
    spotAllocationStrategy: capacity-optimized
  nodeLabels:
    kops.k8s.io/capacity: spot
    kops.k8s.io/architecture: arm64
  taints:
    - architecture=arm64:NoSchedule
  maxSize: 10
  minSize: 0
  role: Node
  rootVolumeSize: 50
  rootVolumeEncryption: true
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  subnets:
    - us-east-1a
    - us-east-1b
    - us-east-1c

Copy link

linux-foundation-easycla bot commented Sep 22, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: guilhermef / name: Guilherme Souza (a4ac273)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Sep 22, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @guilhermef!

It looks like this is your first PR to kubernetes/kops 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kops has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 22, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @guilhermef. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 22, 2024
@guilhermef
Copy link
Contributor Author

/check-cla

@hakman
Copy link
Member

hakman commented Sep 23, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 23, 2024
@hakman
Copy link
Member

hakman commented Sep 23, 2024

@guilhermef Thanks for finding this. Would you mind updating the whole block as described in the docs?
Also, please run hack/update-expected.sh and commit the result.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 23, 2024
@guilhermef
Copy link
Contributor Author

Thanks @hakman, I updated the PR

@guilhermef
Copy link
Contributor Author

/retest

@guilhermef
Copy link
Contributor Author

@hakman, I checked both jobs' logs but couldn't find any failed resource that would prevent the cluster from being created.

@hakman
Copy link
Member

hakman commented Sep 23, 2024

@guilhermef No worries, I will take care of those failing tests. Please also squash the commits. I would like to cherry-pick this PR.

@guilhermef guilhermef force-pushed the fix-cluster-autoscaler-policies branch from 0f76bf0 to a4ac273 Compare September 23, 2024 07:46
@guilhermef
Copy link
Contributor Author

Thanks, @hakman; I squashed the commits.

@hakman
Copy link
Member

hakman commented Sep 23, 2024

/test pull-kops-e2e-k8s-gce-ipalias
/test pull-kops-e2e-k8s-gce-cilium
/override pull-kops-e2e-cni-amazonvpc
/override pull-kops-e2e-cni-amazonvpc

@k8s-ci-robot
Copy link
Contributor

@hakman: Overrode contexts on behalf of hakman: pull-kops-e2e-cni-amazonvpc

In response to this:

/test pull-kops-e2e-k8s-gce-ipalias
/test pull-kops-e2e-k8s-gce-cilium
/override pull-kops-e2e-cni-amazonvpc
/override pull-kops-e2e-cni-amazonvpc

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 23, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 23, 2024
@hakman
Copy link
Member

hakman commented Sep 23, 2024

/override pull-kops-e2e-cni-cilium-eni

@k8s-ci-robot
Copy link
Contributor

@hakman: Overrode contexts on behalf of hakman: pull-kops-e2e-cni-cilium-eni

In response to this:

/override pull-kops-e2e-cni-cilium-eni

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot merged commit e62fdf0 into kubernetes:master Sep 23, 2024
31 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.31 milestone Sep 23, 2024
k8s-ci-robot added a commit that referenced this pull request Sep 25, 2024
…16855-upstream-release-1.30

Automated cherry pick of #16853: fix(cluster-autoscaler): add missing permission
#16855: correct hubble tls file names as mapped from secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants