Skip to content

Commit ed17196

Browse files
authored
feat: support additional pods (#486)
* support additional pods * use our Metadata * Minify CRDs due to size limit * Delete additional pods with their main pod * Add tests * lint * add tests * Apply version to additional pods
1 parent d8c06e8 commit ed17196

File tree

11 files changed

+8030
-31
lines changed

11 files changed

+8030
-31
lines changed

Makefile

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,55 @@ ifndef ignore-not-found
108108
endif
109109

110110
.PHONY: install
111-
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
112-
$(KUSTOMIZE) build config/crd | kubectl apply -f -
111+
install: manifests kustomize ## Install CRDs, RBAC, and Deployment into the K8s cluster specified in ~/.kube/config.
112+
mkdir output
113+
$(KUSTOMIZE) build config/default -o output
114+
go run tools/minify-crd.go -v -o output
115+
cd output && kubectl apply -f .
116+
rm -rf output
117+
118+
install-crds: manifests kustomize ## Install CRDs only into the K8s cluster specified in ~/.kube/config.
119+
mkdir output
120+
$(KUSTOMIZE) build config/crd -o output
121+
go run tools/minify-crd.go -v -o output
122+
cd output && kubectl apply -f .
123+
rm -rf output
113124

114125
.PHONY: uninstall
115126
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
116-
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
127+
mkdir output
128+
$(KUSTOMIZE) build config/default -o output
129+
go run tools/minify-crd.go -v -o output
130+
cd output &&kubectl delete --ignore-not-found=$(ignore-not-found) -f .
131+
rm -rf output
117132

118133
.PHONY: deploy-prerelease
119134
deploy-prerelease: install docker-prerelease ## Install CRDs, build docker image, and deploy a prerelease controller to the K8s cluster specified in ~/.kube/config.
120135
cd config/manager && $(KUSTOMIZE) edit set image controller=$(PRE_IMG)
121-
$(KUSTOMIZE) build config/default | kubectl apply -f -
136+
mkdir output
137+
$(KUSTOMIZE) build config/default -o output
138+
go run tools/minify-crd.go -v -o output
139+
cd output && kubectl apply -f .
140+
rm -rf output
122141
@#Hack to reset tag to avoid git thrashing.
123142
@cd config/manager && $(KUSTOMIZE) edit set image controller=ghcr.io/strangelove-ventures/cosmos-operator:latest
124143

125144
.PHONY: deploy
126145
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
127146
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
128-
$(KUSTOMIZE) build config/default | kubectl apply -f -
147+
mkdir output
148+
$(KUSTOMIZE) build config/default -o output
149+
go run tools/minify-crd.go -v -o output
150+
cd output && kubectl apply -f .
151+
rm -rf output
129152

130153
.PHONY: undeploy
131154
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
132-
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
155+
mkdir output
156+
$(KUSTOMIZE) build config/default -o output
157+
go run tools/minify-crd.go -v -o output
158+
cd output && kubectl delete --ignore-not-found=$(ignore-not-found) -f .
159+
rm -rf output
133160

134161
##@ Build Dependencies
135162

api/v1/cosmosfullnode_types.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ type FullNodeSpec struct {
7575
// Creates 1 pod per replica.
7676
PodTemplate PodSpec `json:"podTemplate"`
7777

78+
// Additional pod specs to apply per replica.
79+
// This is useful for adding additional pods to the deployment
80+
// that need to be versioned alongside the main pod.
81+
// +optional
82+
AdditionalVersionedPods []AdditionalPodSpec `json:"additionalVersionedPods"`
83+
7884
// How to scale pods when performing an update.
7985
// +optional
8086
RolloutStrategy RolloutStrategy `json:"strategy"`
@@ -321,6 +327,18 @@ type PodSpec struct {
321327
Containers []corev1.Container `json:"containers"`
322328
}
323329

330+
type AdditionalPodSpec struct {
331+
// Name of the additional pod.
332+
// +kubebuilder:validation:MinLength:=1
333+
Name string `json:"name"`
334+
335+
// Metadata applied to the additional pod.
336+
// +optional
337+
Metadata Metadata `json:"metadata"`
338+
339+
corev1.PodSpec `json:",inline"`
340+
}
341+
324342
type FullNodeProbeStrategy string
325343

326344
const (

api/v1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)