@@ -6,6 +6,8 @@ PATH := $(SELF)/bin:$(PATH)
66SHELL = /usr/bin/env bash -o pipefail
77.SHELLFLAGS = -ec
88
9+ CHARTS_DIR := $(SELF ) /_charts
10+
911# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
1012ifeq (,$(shell go env GOBIN) )
1113GOBIN := $(shell go env GOPATH) /bin
@@ -14,10 +16,12 @@ GOBIN := $(shell go env GOBIN)
1416endif
1517
1618ENVSUBST_VERSION ?= 1.4.2
19+ HELM_VERSION ?= 3.17.3
1720KUBECTL_VERSION ?= 1.31.4
1821KUSTOMIZE_VERSION ?= 5.6.0
1922
2023ENVSUBST := $(SELF ) /bin/envsubst
24+ HELM := $(SELF ) /bin/helm
2125KUBECTL := $(SELF ) /bin/kubectl
2226KUSTOMIZE := $(SELF ) /bin/kustomize
2327
@@ -84,28 +88,67 @@ docker-release:
8488 $(CONTAINER_TOOL ) buildx build --push --platform=$(_PLATFORMS ) -t $(IMG_URL ) :$(CLOSEST_TAG ) -t $(IMG_URL ) :latest -f Dockerfile .
8589 -$(CONTAINER_TOOL ) buildx rm cloud-provider-opennebula-builder
8690
91+ # Helm
92+
93+ .PHONY : charts
94+
95+ define chart-generator-tool
96+ charts: $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) -$(subst v,,$(CLOSEST_TAG ) ) .tgz
97+
98+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) -$(subst v,,$(CLOSEST_TAG ) ) .tgz: $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) $(HELM )
99+ $(HELM ) package -d $(CHARTS_DIR ) /$(CLOSEST_TAG ) $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 )
100+
101+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : CCM_IMG := {{ tpl .Values.CCM_IMG . }}
102+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : CCM_CTL := {{ .Values.CCM_CTL }}
103+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : CLUSTER_NAME := {{ .Values.CLUSTER_NAME }}
104+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : NODE_SELECTOR := {{ (toYaml .Values.nodeSelector) | nindent 8 }}
105+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : ONE_AUTH := {{ .Values.ONE_AUTH }}
106+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : ONE_XMLRPC := {{ .Values.ONE_XMLRPC }}
107+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : PRIVATE_NETWORK_NAME := {{ .Values.PRIVATE_NETWORK_NAME }}
108+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : PUBLIC_NETWORK_NAME := {{ .Values.PUBLIC_NETWORK_NAME }}
109+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : ROUTER_TEMPLATE_NAME := {{ tpl .Values.ROUTER_TEMPLATE_NAME . }}
110+
111+ $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) : $(KUSTOMIZE ) $(ENVSUBST )
112+ install -m u=rwx,go=rx -d $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 )
113+ cp -rf helm/$(1 ) $(CHARTS_DIR ) /$(CLOSEST_TAG ) /.
114+ $(KUSTOMIZE ) build kustomize/$(2 ) | $(ENVSUBST ) \
115+ | install -m u=rw,go=r -D /dev/fd/0 $(CHARTS_DIR ) /$(CLOSEST_TAG ) /$(1 ) /templates/opennebula-cpi.yaml
116+ endef
117+
118+ $(eval $(call chart-generator-tool,opennebula-cpi,base))
119+
87120# Deployment
88121
89122ifndef ignore-not-found
90123ignore-not-found := false
91124endif
92125
93- .PHONY : deploy undeploy
126+ .PHONY : deploy-kadm undeploy-kadm deploy-rke2 undeploy-rke2
94127
95- deploy : $(KUSTOMIZE ) $(ENVSUBST ) $(KUBECTL ) # Deploy controller to the K8s cluster specified in ~/.kube/config.
96- $(KUSTOMIZE ) build kustomize/base/ | $(ENVSUBST ) | $(KUBECTL ) apply -f-
128+ # Deploy controller to the K8s cluster specified in ~/.kube/config.
129+ deploy-kadm deploy-rke2 : deploy-% : $(KUSTOMIZE ) $(ENVSUBST ) $(KUBECTL )
130+ $(KUSTOMIZE ) build kustomize/$* / | $(ENVSUBST ) | $(KUBECTL ) apply -f-
97131
98- undeploy : $(KUSTOMIZE ) $(ENVSUBST ) $(KUBECTL ) # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
99- $(KUSTOMIZE ) build kustomize/base/ | $(ENVSUBST ) | $(KUBECTL ) --ignore-not-found=$(ignore-not-found ) delete -f-
132+ # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
133+ undeploy-kadm undeploy-rke2 : undeploy-% : $(KUSTOMIZE ) $(ENVSUBST ) $(KUBECTL )
134+ $(KUSTOMIZE ) build kustomize/$* / | $(ENVSUBST ) | $(KUBECTL ) --ignore-not-found=$(ignore-not-found ) delete -f-
100135
101136# Dependencies
102137
103- .PHONY : envsubst kubectl kustomize
138+ .PHONY : envsubst helm kubectl kustomize
104139
105140envsubst : $(ENVSUBST )
106141$(ENVSUBST ) :
107142 $(call go-install-tool,$(ENVSUBST ) ,github.com/a8m/envsubst/cmd/envsubst,v$(ENVSUBST_VERSION ) )
108143
144+ helm : $(HELM )
145+ $(HELM ) :
146+ @[ -f $@ -v$( HELM_VERSION) ] || \
147+ { curl -fsSL https://get.helm.sh/helm-v$( HELM_VERSION) -linux-amd64.tar.gz \
148+ | tar -xzO -f- linux-amd64/helm \
149+ | install -m u=rwx,go= -o $(USER ) -D /dev/fd/0 $@ -v$(HELM_VERSION ) ; }
150+ @ln -sf $@ -v$(HELM_VERSION ) $@
151+
109152kubectl : $(KUBECTL )
110153$(KUBECTL ) :
111154 @[ -f $@ -v$( KUBECTL_VERSION) ] || \
0 commit comments