Skip to content

Commit 18e1db7

Browse files
committed
chore: update README and minor cleanups
Signed-off-by: Dinar Valeev <k0da@opensuse.org>
1 parent f6fdee0 commit 18e1db7

File tree

11 files changed

+76
-48
lines changed

11 files changed

+76
-48
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
karpenter-provider-vsphere
1+
# karpenter-provider-vsphere
2+
3+
Karpenter provider for VMWare Vsphere
4+
5+
# Required flags
6+
7+
| Flag | Environment variable | Required |
8+
|------------------|----------------------|----------|
9+
|cluster-name | CLUSTER_NAME | true |
10+
| vsphere-endpoint | GOVC_URL | true |
11+
| vsphere-username | GOVC_USERNAME | true |
12+
| vsphere-password | GOVC_PASSWORD | true |
13+
| vsphere-path | VSPHERE_PATH | true |
14+
| vsphere-insecure | VSPHERE_INSECURE | false |
15+
16+
# VsphereNodeClass API
17+
Besides `VSPHERE_PATH` (vsphere folder to place virtulal machines on), all placement settings are defined in `VsphereNodeClass` resource. This is done via selectors:
18+
* `.spec.computeSelector` - defines how to search for desired resourcePool
19+
* `.spec.datastoreSelector` - defines how to search for desired datastore
20+
* `.spec.networkSelector` - difines how to discover network
21+
* `.spec.imageSelector` - VM Template to use for VM Clone
22+
23+
All selectors have `tag` and `name` properties, those are mutually exclusive. Karpenter will find a resource either by Tag or Name.
24+
[!NOTE]
25+
Due to nature of Vsphere tags. Only 1 uniquie tag could be selected to identify desired resource
26+
27+
28+
* `.spec.instanceTypes` - a list of desired instance types, in a following format: `%cpu-%mem-%os`, e.g. 8-16-linux
29+
* `.spec.diskSize` - a desired root volume size in Gigabytes
30+
31+
* `.spec.tags` - a list of tags to apply to Karpenter managed virtual machines
32+
[!NOTE]
33+
At least two tags must be specified explicitly:
34+
* `topology.kubernetes.io/zone` and `k8s-zone` to satisfy Vsphere Cloud controller manager which bootstraps Kubernetes node and removes `unitialized` Taint.
35+
36+
37+
* `.spec.userdata`:
38+
- `type` - Either `ignition` or `cloud-init`
39+
- `templateBase64` - A base64 encoded template
40+
- `values` - a v1.Secret reference (name/namespace) to key/values used in a template

charts/karpenter-crd/templates/karpenter.vsphere.com_vspherenodeclasses.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ spec:
138138
- message: empty tag keys or values aren't supported
139139
rule: self.all(k, k != '' && self[k] != '')
140140
type: object
141+
tags:
142+
additionalProperties:
143+
type: string
144+
type: object
141145
userData:
142146
properties:
143147
templateBase64:

charts/karpenter/crds/karpenter.vsphere.com_vspherenodeclasses.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ spec:
135135
- message: empty tag keys or values aren't supported
136136
rule: self.all(k, k != '' && self[k] != '')
137137
type: object
138+
tags:
139+
additionalProperties:
140+
type: string
141+
type: object
138142
userData:
139143
properties:
140144
templateBase64:

charts/karpenter/templates/deployment.yaml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ spec:
8989
image: {{ include "karpenter.controller.image" . }}
9090
imagePullPolicy: {{ .Values.imagePullPolicy }}
9191
env:
92-
- name: KUBERNETES_MIN_VERSION
93-
value: "1.19.0-0"
9492
- name: KARPENTER_SERVICE
9593
value: {{ include "karpenter.fullname" . }}
9694
{{- with .Values.logLevel }}
@@ -130,37 +128,9 @@ spec:
130128
{{- with .Values.settings.preferencePolicy }}
131129
- name: PREFERENCE_POLICY
132130
value: "{{ . }}"
133-
{{- end }}
134-
{{- with .Values.settings.clusterCABundle }}
135-
- name: CLUSTER_CA_BUNDLE
136-
value: "{{ tpl (toString .) $ }}"
137131
{{- end }}
138132
- name: CLUSTER_NAME
139133
value: "{{ required "Chart cannot be installed without a valid settings.clusterName!" (tpl .Values.settings.clusterName .) }}"
140-
{{- with .Values.settings.clusterEndpoint }}
141-
- name: CLUSTER_ENDPOINT
142-
value: "{{ tpl (toString .) $ }}"
143-
{{- end }}
144-
{{- with .Values.settings.isolatedVPC }}
145-
- name: ISOLATED_VPC
146-
value: "{{ tpl (toString .) $ }}"
147-
{{- end }}
148-
{{- with .Values.settings.eksControlPlane }}
149-
- name: EKS_CONTROL_PLANE
150-
value: "{{ tpl (toString .) $ }}"
151-
{{- end }}
152-
{{- with .Values.settings.vmMemoryOverheadPercent }}
153-
- name: VM_MEMORY_OVERHEAD_PERCENT
154-
value: "{{ tpl (toString .) $ }}"
155-
{{- end }}
156-
{{- with .Values.settings.interruptionQueue }}
157-
- name: INTERRUPTION_QUEUE
158-
value: "{{ tpl (toString .) $ }}"
159-
{{- end }}
160-
{{- with .Values.settings.reservedENIs }}
161-
- name: RESERVED_ENIS
162-
value: "{{ tpl (toString .) $ }}"
163-
{{- end }}
164134
{{- with .Values.controller.env }}
165135
{{- toYaml . | nindent 12 }}
166136
{{- end }}

pkg/apis/crds/karpenter.vsphere.com_vspherenodeclasses.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ spec:
135135
- message: empty tag keys or values aren't supported
136136
rule: self.all(k, k != '' && self[k] != '')
137137
type: object
138+
tags:
139+
additionalProperties:
140+
type: string
141+
type: object
138142
userData:
139143
properties:
140144
templateBase64:

pkg/apis/v1alpha1/vspherenodeclass.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type VsphereNodeClassSpec struct {
100100
DiskSize int64 `json:"diskSize,omitempty"`
101101
InstanceTypes []string `json:"instanceTypes,omitempty"`
102102
UserData UserData `json:"userData,omitempty"`
103+
Tags map[string]string `json:"tags,omitempty"`
103104
}
104105

105106
type UserDataType string

pkg/apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cloudprovider/cloudprovider.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ func (c *CloudProvider) Create(ctx context.Context, nodeClaim *karpv1.NodeClaim)
8989
if len(instanceTypes) == 0 {
9090
return nil, cloudprovider.NewInsufficientCapacityError(fmt.Errorf("all requested instance types were unavailable during launch"))
9191
}
92-
nodePoolName := nodeClaim.Labels[karpv1.NodePoolLabelKey]
93-
instance, err := c.instanceProvider.Create(ctx, nodeClass, nodeClaim, instanceTypes, nodePoolName)
92+
instance, err := c.instanceProvider.Create(ctx, nodeClass, nodeClaim, instanceTypes)
9493
if err != nil {
9594
return nil, cloudprovider.NewCreateError(fmt.Errorf("creating instance failed, %w", err), CreateInstanceFailedReason, err.Error())
9695
}

pkg/operator/operator.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont
6262
inClusterClient,
6363
finderProvider,
6464
options.FromContext(ctx).ClusterName,
65-
options.FromContext(ctx).VsphereZone,
6665
)
6766
return ctx, &Operator{
6867
Operator: operator,

pkg/providers/finder/tags.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/vmware/govmomi/vapi/tags"
99
"github.com/vmware/govmomi/vim25/types"
1010
corev1 "k8s.io/api/core/v1"
11+
"sigs.k8s.io/controller-runtime/pkg/log"
1112
)
1213

1314
func (t *Provider) getObjectByType(ctx context.Context, tag *tags.Tag, objT string) (*types.ManagedObjectReference, error) {
@@ -164,7 +165,7 @@ func getCategoryObject(name string) *tags.Category {
164165
func (t *Provider) TagsFromVM(ctx context.Context, vm *object.VirtualMachine) (map[string]string, error) {
165166
tagsAttached, err := t.TagManager.ListAttachedTags(ctx, vm.Reference())
166167
if err != nil {
167-
fmt.Printf("Failed to list tags for VM %s: %v\n", vm.Name(), err)
168+
log.FromContext(ctx).Error(err, fmt.Sprintf("failed to list tags for VM %s", vm.Name()))
168169
}
169170
return extractTagInfo(ctx, t.TagManager, tagsAttached)
170171

0 commit comments

Comments
 (0)