Skip to content

Commit

Permalink
feat: use more accurate projectID + Kubernetes node name method to re…
Browse files Browse the repository at this point in the history
…trieve instance info if available
  • Loading branch information
Clement Liaw committed Oct 23, 2024
1 parent 261684f commit f6b99f9
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 76 deletions.
7 changes: 6 additions & 1 deletion charts/crusoe-csi-driver/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ spec:
containers:
- name: crusoe-csi-driver
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: Always
args:
- "--services=controller,identity"
- "--socket-address=unix:/csi/csi-controller.sock"
Expand All @@ -30,9 +31,13 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- with .Values.crusoe.projectID }}
- name: CRUSOE_PROJECT_ID
value: {{ . }}
{{- end }}
envFrom:
- secretRef:
name: {{.Values.secrets.crusoe_api_keys.secretName}}
name: {{.Values.secrets.crusoeApiKeys.secretName}}
optional: false
volumeMounts:
- name: socket-dir
Expand Down
8 changes: 7 additions & 1 deletion charts/crusoe-csi-driver/templates/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ spec:
spec:
imagePullSecrets:
- name: registry-credentials
serviceAccountName: crusoe-csi-driver-node-sa
containers:
- name: crusoe-csi-driver
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: Always
args:
- "--services=node,identity"
- "--socket-address=unix:/csi/csi-node.sock"
Expand All @@ -28,9 +30,13 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- with .Values.crusoe.projectID }}
- name: CRUSOE_PROJECT_ID
value: {{ . }}
{{- end }}
envFrom:
- secretRef:
name: {{.Values.secrets.crusoe_api_keys.secretName}}
name: {{.Values.secrets.crusoeApiKeys.secretName}}
optional: false
volumeMounts:
- name: socket-dir
Expand Down
32 changes: 32 additions & 0 deletions charts/crusoe-csi-driver/templates/node_rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file contains the objects representing the Service
# Accounts and RBAC tied to that account that need to be
# made for the CSI controller deployment. This is so the
# CSI node agent can fetch the Crusoe project ID from the
# node labels, if it exists.
apiVersion: v1
kind: ServiceAccount
metadata:
name: crusoe-csi-driver-node-sa
namespace: {{ .Release.Namespace }}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: crusoe-csi-driver-node-read-labels
rules:
- apiGroups: [ "" ]
resources: [ "nodes" ]
verbs: [ "get", "list", "watch" ]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: crusoe-csi-driver-node-read-labels
subjects:
- kind: ServiceAccount
name: crusoe-csi-driver-node-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: crusoe-csi-driver-node-read-labels
apiGroup: rbac.authorization.k8s.io
5 changes: 4 additions & 1 deletion charts/crusoe-csi-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ image:
repository: ghcr.io/crusoecloud/crusoe-csi-driver
tag: "main"

crusoe:
projectID: ""

secrets:
crusoe_api_keys:
crusoeApiKeys:
secretName: "crusoe-api-keys"
controller:
resources:
Expand Down
49 changes: 39 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,53 @@ require (
github.com/antihax/optional v1.0.0
github.com/container-storage-interface/spec v1.9.0
github.com/crusoecloud/client-go v0.1.59
github.com/google/uuid v1.6.0
github.com/spf13/cobra v1.8.0
google.golang.org/grpc v1.57.0
k8s.io/klog/v2 v2.120.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
k8s.io/klog/v2 v2.130.1
k8s.io/mount-utils v0.30.1
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
)

require (
github.com/go-logr/logr v1.4.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.31.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit f6b99f9

Please sign in to comment.