Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify config for sidecar and init containers #193

Merged
merged 8 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linters:
- goimports
- dupl
- errcheck
- exportloopref
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply --server-side -f -

.PHONY: uninstall
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.
Expand Down Expand Up @@ -167,7 +167,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
KUSTOMIZE_VERSION ?= v5.4.1
CONTROLLER_TOOLS_VERSION ?= v0.16.2
ENVTEST_VERSION ?= latest
GOLANGCI_LINT_VERSION ?= v1.57.2
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
31 changes: 12 additions & 19 deletions api/v1/chiacommon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ type CommonSpec struct {

// InitContainers allows defining a list of containers that will run as init containers in the kubernetes Pods this resource creates
// +optional
InitContainers []InitContainer `json:"initContainers,omitempty"`
InitContainers []ExtraContainer `json:"initContainers,omitempty"`

// Sidecars allows defining a list of containers and volumes that will share the kubernetes Pod alongside Chia containers
// Sidecars allows defining a list of containers and volumes that will share the kubernetes Pod alongside a Chia container
// +optional
Sidecars Sidecars `json:"sidecars,omitempty"`
Sidecars []ExtraContainer `json:"sidecars,omitempty"`

//StorageConfig defines the Chia container's CHIA_ROOT storage config
// +optional
Expand Down Expand Up @@ -48,30 +48,23 @@ type CommonSpec struct {
Affinity *corev1.Affinity `json:"affinity,omitempty"`
}

// InitContainer allows defining a container that will run as an init container for a kubernetes resource
type InitContainer struct {
// Container allows defining a container that will share the kubernetes Pod alongside Chia containers.
// ExtraContainer allows defining a container spec that will share the kubernetes Pod alongside a Chia container, or run as an init container, along with some additional Pod spec configuration
type ExtraContainer struct {
// Container allows defining a container spec that will share the kubernetes Pod alongside a Chia container
// +optional
Container corev1.Container `json:"container,omitempty"`

// ShareVolumeMounts if set to true, shares any volume mounts from the main chia container to this init container
// Volumes allows defining a list of volumes that can be mounted by this container
// +optional
ShareVolumeMounts bool `json:"shareVolumeMounts,omitempty"`

// ShareEnv if set to true, shares the environment variables from the main chia container. Useful if the init container's image is a derivative of the chia-docker image.
// +optional
ShareEnv bool `json:"shareEnv,omitempty"`
}
Volumes []corev1.Volume `json:"volumes,omitempty"`

// Sidecars allows defining a list of containers that will share the kubernetes Pod alongside Chia containers
type Sidecars struct {
// Containers allows defining a list of containers that will share the kubernetes Pod alongside Chia containers
// ShareVolumeMounts if set to true, shares any volume mounts from the main chia container to this container
// +optional
Containers []corev1.Container `json:"containers,omitempty"`
ShareVolumeMounts bool `json:"shareVolumeMounts,omitempty"`

// Volumes allows defining a list of volumes that can be mounted by sidecar containers
// ShareEnv if set to true, shares the environment variables from the main chia container to this container
// +optional
Volumes []corev1.Volume `json:"volumes,omitempty"`
ShareEnv bool `json:"shareEnv,omitempty"`
}

// CommonSpecChia represents the common configuration options for a chia spec
Expand Down
64 changes: 24 additions & 40 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading