Skip to content

Commit

Permalink
Changes post PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Giacomo Tomolillo committed Oct 16, 2023
1 parent b7aed6c commit 06b1203
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
3 changes: 1 addition & 2 deletions tools/karpenter-convert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Usage:
Flags:
-f, --filename strings Filename, directory, or URL to files to need to get converted.
-h, --help help for karpenter-convert
-I, --ignore-defaults Ignore defining default requirements when migrating Provisioners to NodePool.
-k, --kustomize string Process the kustomization directory. This flag can't be used together with -f or -R.
--ignore-defaults Ignore defining default requirements when migrating Provisioners to NodePool.
-o, --output string Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). (default "yaml")
-R, --recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
```
Expand Down
16 changes: 10 additions & 6 deletions tools/karpenter-convert/pkg/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import (
"github.com/aws/karpenter/pkg/apis/v1alpha5"
)

const karpenterNodeRolePlaceholder string = "$KARPENTER_NODE_ROLE"

type Context struct {
PrintFlags *genericclioptions.PrintFlags
Printer printers.ResourcePrinter
Expand All @@ -72,18 +74,20 @@ func NewCmd(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Comm
},
}

rootCmd.Flags().BoolVarP(&o.IgnoreDefaults, "ignore-defaults", "I", o.IgnoreDefaults, "Ignore defining default requirements when migrating Provisioners to NodePool.")
cmdutil.AddFilenameOptionFlags(rootCmd, &o.FilenameOptions, "to need to get converted.")
rootCmd.Flags().BoolVar(&o.IgnoreDefaults, "ignore-defaults", o.IgnoreDefaults, "Ignore defining default requirements when migrating Provisioners to NodePool.")
cmdutil.AddJsonFilenameFlag(rootCmd.Flags(), &o.Filenames, "Filename, directory, or URL to files to need to get converted.")
rootCmd.Flags().BoolVarP(&o.Recursive, "recursive", "R", o.Recursive, "Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.")

o.PrintFlags.AddFlags(rootCmd)

return rootCmd
}

func (o *Context) Complete(f cmdutil.Factory, _ *cobra.Command) (err error) {
err = o.FilenameOptions.RequireFilenameOrKustomize()
if err != nil {
return err
if len(o.Filenames) == 0 {
return fmt.Errorf("must specify -f")
}

o.builder = f.NewBuilder
o.Printer, err = o.PrintFlags.ToPrinter()
return err
Expand Down Expand Up @@ -208,7 +212,7 @@ func convertNodeTemplate(resource runtime.Object) runtime.Object {
nodeclass.Status = v1beta1.EC2NodeClassStatus{}

// Leave a placeholder for the role. This can be substituted with `envsubst` or other means
nodeclass.Spec.Role = "$KARPENTER_NODE_ROLE"
nodeclass.Spec.Role = karpenterNodeRolePlaceholder
return nodeclass
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: karpenter.k8s.aws/v1beta1
kind: EC2NodeClass
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"karpenter.k8s.aws/v1alpha1","kind":"AWSNodeTemplate","metadata":{"annotations":{},"name":"default"},"spec":{"securityGroupSelector":{"karpenter.sh/discovery":"eks-workshop-camigration"},"subnetSelector":{"karpenter.sh/discovery":"eks-workshop-camigration"},"tags":{"app.kubernetes.io/created-by":"eks-workshop","aws-node-termination-handler/managed":"true"}}}
name: default
spec:
amiFamily: AL2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: karpenter.sh/v1beta1
kind: NodePool
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"karpenter.sh/v1alpha5","kind":"Provisioner","metadata":{"annotations":{},"name":"provisioner1"},"spec":{"labels":{"type":"app1"},"limits":{"resources":{"cpu":100,"memory":"1000Gi"}},"providerRef":{"name":"default"},"requirements":[{"key":"karpenter.sh/capacity-type","operator":"In","values":["on-demand"]},{"key":"node.kubernetes.io/instance-family","operator":"In","values":["c","r","m"]}]}}
name: provisioner1
spec:
disruption:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: karpenter.k8s.aws/v1alpha1
kind: AWSNodeTemplate
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"karpenter.k8s.aws/v1alpha1","kind":"AWSNodeTemplate","metadata":{"annotations":{},"name":"default"},"spec":{"securityGroupSelector":{"karpenter.sh/discovery":"eks-workshop-camigration"},"subnetSelector":{"karpenter.sh/discovery":"eks-workshop-camigration"},"tags":{"app.kubernetes.io/created-by":"eks-workshop","aws-node-termination-handler/managed":"true"}}}
creationTimestamp: "2023-05-08T13:37:43Z"
generation: 2
name: default
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: karpenter.sh/v1alpha5
kind: Provisioner
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"karpenter.sh/v1alpha5","kind":"Provisioner","metadata":{"annotations":{},"name":"provisioner1"},"spec":{"labels":{"type":"app1"},"limits":{"resources":{"cpu":100,"memory":"1000Gi"}},"providerRef":{"name":"default"},"requirements":[{"key":"karpenter.sh/capacity-type","operator":"In","values":["on-demand"]},{"key":"node.kubernetes.io/instance-family","operator":"In","values":["c","r","m"]}]}}
creationTimestamp: "2023-07-10T13:41:16Z"
generation: 1
name: provisioner1
Expand Down

0 comments on commit 06b1203

Please sign in to comment.