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

Relax soft constraints if pods cannot be scheduled #705

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

ellistarn
Copy link
Contributor

@ellistarn ellistarn commented Sep 24, 2021

1. Issue, if available:
#417

2. Description of changes:
Useful for:

  • AZ Preferences (and regional fallback)
  • Spot Preferences (and OD fallback)

3. Does this change impact docs?

Testing

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: inflate
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: inflate
  template:
    metadata:
      labels:
        app: inflate
    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - preference:
              matchExpressions:
              - key: node.k8s.aws/capacity-type
                operator: In
                values:
                - spot
            weight: 1
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: node.kubernetes.io/instance-type
                operator: In
                values:
                - m5.large
              - key: topology.kubernetes.io/zone
                operator: In
                values:
                - us-west-2a
      containers:
      - image: public.ecr.aws/eks-distro/kubernetes/pause:3.2
        imagePullPolicy: Always
        name: inflate
        resources:
          requests:
            cpu: "1"
      nodeSelector:
        karpenter.sh/provisioner-name: default

provisioner.yaml

apiVersion: karpenter.sh/v1alpha4
kind: Provisioner
metadata:
  name: default
spec:
  architectures:
  - amd64
  provider:
    apiVersion: extensions.karpenter.sh/v1alpha1
    capacityTypes:
    - spot
    - on-demand
    cluster:
      endpoint: https://BE5C79AC824BB1EF67DB8CC14D6A263F.gr7.us-west-2.eks.amazonaws.com
      name: etarn
    instanceProfile: KarpenterNodeInstanceProfile-etarn
    kind: AWS
  ttlSecondsAfterEmpty: 30
Starting provisioning loop
Waiting to batch additional pods
Found 1 provisionable pods
Computed packing for 1 pod(s) with instance type option(s) [c5a.24xlarge]
Discovered subnets: [subnet-0f3fa09b6ca9de74a subnet-05ad119d43b8c07b3]
Discovered kubernetes version 1.20
Discovered ami ami-0494b922d4a70c8d6 for query /aws/service/eks/optimized-ami/1.20/amazon-linux-2/recommended/image_id
Discovered security groups: [sg-000d68e67c3fe53d8 sg-0c8c73058f4cbaaaa]
Discovered caBundle, length 1025
Discovered launch template Karpenter-etarn-10670878007216278433
error	{"commit": "027bab6", "reconciler group": "karpenter.sh", "reconciler kind": "Provisioner", "name": "default", "namespace": "", "error": "launching instance, with fleet error(s), UnfulfillableCapacity: Unable to fulfill capacity due to your request configuration. Please adjust your request and try again."}
Starting provisioning loop
Waiting to batch additional pods
Found 1 provisionable pods
Pod inflate-7c8c66dbcd-b586k/default previously failed to schedule, removing soft constraint: spec.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution[0]={"weight":1,"preference":{"matchExpressions":[{"key":"node.k8s.aws/capacity-type","operator":"In","values":["spot"]}]}}
Computed packing for 1 pod(s) with instance type option(s) [c5a.24xlarge]
Discovered caBundle, length 1025
Launched instance: i-0c262704459ede77b, type: c5a.24xlarge, zone: us-west-2a, hostname: ip-192-168-75-12.us-west-2.compute.internal
Bound 1 pod(s) to node ip-192-168-75-12.us-west-2.compute.internal

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@netlify
Copy link

netlify bot commented Sep 24, 2021

✔️ Deploy Preview for karpenter-docs-prod canceled.

🔨 Explore the source changes: 855c58a

🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/6153a5f3aec65900076de5de

Copy link
Contributor

@JacobGabrielson JacobGabrielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me so far

@ellistarn ellistarn force-pushed the soft_pref branch 2 times, most recently from 0dafcf7 to a95054f Compare September 27, 2021 21:25
@ellistarn ellistarn changed the title [WIP] Relax soft constraints if pods cannot be scheduled Relax soft constraints if pods cannot be scheduled Sep 27, 2021
pkg/controllers/allocation/controller.go Outdated Show resolved Hide resolved
pod := test.UnschedulablePod()
pod.Spec.Affinity = &v1.Affinity{NodeAffinity: &v1.NodeAffinity{RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{NodeSelectorTerms: []v1.NodeSelectorTerm{
{MatchExpressions: []v1.NodeSelectorRequirement{
{Key: v1.LabelTopologyZone, Operator: v1.NodeSelectorOpIn, Values: []string{"invalid"}}, // Should not be relaxed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking - it should not be relaxed because it's the last (only) one?

Copy link
Contributor Author

@ellistarn ellistarn Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. You can't remove all the hard requirements otherwise they wouldn't be very hard =/

@ellistarn ellistarn force-pushed the soft_pref branch 7 times, most recently from ad84ee8 to 419ee38 Compare September 28, 2021 22:01
@@ -75,6 +75,8 @@ spec:
operator: In
values:
- linux
- key: karpenter.sh/provisioner-name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@ellistarn ellistarn merged commit b282919 into aws:main Sep 29, 2021
@ellistarn ellistarn deleted the soft_pref branch September 29, 2021 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants