Skip to content
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
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@ jobs:
CHIA_IMAGE_TAG=$(curl -fsSL https://latest.cmm.io/chia)
EXPORTER_IMAGE_TAG=$(curl -fsSL https://latest.cmm.io/chia-exporter)
HEALTHCHECK_IMAGE_TAG=$(curl -fsSL https://latest.cmm.io/chia-healthcheck)
DBPULL_IMAGE_TAG=$(curl -fsSL https://latest.cmm.io/chia-db-pull)

# Verify all variables are set
if [ -z "$CHIA_IMAGE_TAG" ] || [ -z "$EXPORTER_IMAGE_TAG" ] || [ -z "$HEALTHCHECK_IMAGE_TAG" ]; then
if [ -z "$CHIA_IMAGE_TAG" ] || [ -z "$EXPORTER_IMAGE_TAG" ] || [ -z "$HEALTHCHECK_IMAGE_TAG" ] || [ -z "$DBPULL_IMAGE_TAG" ]; then
echo "Error: Failed to fetch one or more version tags"
echo "CHIA_IMAGE_TAG=$CHIA_IMAGE_TAG"
echo "EXPORTER_IMAGE_TAG=$EXPORTER_IMAGE_TAG"
echo "HEALTHCHECK_IMAGE_TAG=$HEALTHCHECK_IMAGE_TAG"
echo "DBPULL_IMAGE_TAG=$DBPULL_IMAGE_TAG"
exit 1
fi

echo "CHIA_IMAGE_TAG=$CHIA_IMAGE_TAG" >> $GITHUB_ENV
echo "EXPORTER_IMAGE_TAG=$EXPORTER_IMAGE_TAG" >> $GITHUB_ENV
echo "HEALTHCHECK_IMAGE_TAG=$HEALTHCHECK_IMAGE_TAG" >> $GITHUB_ENV
echo "DBPULL_IMAGE_TAG=$DBPULL_IMAGE_TAG" >> $GITHUB_ENV

- name: Build Container
uses: Chia-Network/actions/docker/build@main
Expand All @@ -56,3 +59,4 @@ jobs:
"CHIA_IMAGE_TAG=${{ env.CHIA_IMAGE_TAG }}"
"EXPORTER_IMAGE_TAG=${{ env.EXPORTER_IMAGE_TAG }}"
"HEALTHCHECK_IMAGE_TAG=${{ env.HEALTHCHECK_IMAGE_TAG }}"
"DBPULL_IMAGE_TAG=${{ env.DBPULL_IMAGE_TAG }}"
Comment thread
cursor[bot] marked this conversation as resolved.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ linters:
- dupl
- lll
path: internal/*
# ChiaNode Reconcile function complexity has become too high
- linters:
- gocyclo
path: internal/controller/chianode/controller.go
paths:
- third_party$
- builtin$
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ FROM golang:1 AS builder
ARG CHIA_IMAGE_TAG=latest
ARG EXPORTER_IMAGE_TAG=latest
ARG HEALTHCHECK_IMAGE_TAG=latest
ARG DBPULL_IMAGE_TAG=latest

ENV CHIA_IMAGE_TAG=${CHIA_IMAGE_TAG}
ENV EXPORTER_IMAGE_TAG=${EXPORTER_IMAGE_TAG}
ENV HEALTHCHECK_IMAGE_TAG=${HEALTHCHECK_IMAGE_TAG}
ENV DBPULL_IMAGE_TAG=${DBPULL_IMAGE_TAG}

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ ENVTEST_K8S_VERSION = 1.30.0
CHIA_IMAGE_TAG ?= latest
EXPORTER_IMAGE_TAG ?= latest
HEALTHCHECK_IMAGE_TAG ?= latest
DBPULL_IMAGE_TAG ?= latest
CHIA_OPERATOR_VERSION ?= latest

LD_FLAGS := \
-X 'github.com/chia-network/chia-operator/internal/controller/common/consts.DefaultChiaImageTag=$(CHIA_IMAGE_TAG)' \
-X 'github.com/chia-network/chia-operator/internal/controller/common/consts.DefaultChiaExporterImageTag=$(EXPORTER_IMAGE_TAG)' \
-X 'github.com/chia-network/chia-operator/internal/controller/common/consts.DefaultChiaHealthcheckImageTag=$(HEALTHCHECK_IMAGE_TAG)'
-X 'github.com/chia-network/chia-operator/internal/controller/common/consts.DefaultChiaHealthcheckImageTag=$(HEALTHCHECK_IMAGE_TAG)' \
-X 'github.com/chia-network/chia-operator/internal/controller/common/consts.DefaultChiaDBPullImageTag=$(DBPULL_IMAGE_TAG)'

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down
56 changes: 56 additions & 0 deletions api/v1/chianode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package v1

import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -20,6 +21,12 @@ type ChiaNodeSpec struct {
// +optional
ChiaHealthcheckConfig SpecChiaHealthcheck `json:"chiaHealthcheck,omitempty"`

// ChiaDBPullConfig defines the configuration options available to an optional chia-db-pull init container
// that downloads a chia blockchain database from an S3-compatible bucket into CHIA_ROOT before the chia
// container starts.
// +optional
ChiaDBPullConfig SpecChiaDBPull `json:"chiaDBPull,omitempty"`

// Replicas is the desired number of replicas of the given Statefulset. defaults to 1.
// +optional
// +kubebuilder:default=1
Expand All @@ -30,6 +37,55 @@ type ChiaNodeSpec struct {
UpdateStrategy *appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
}

// SpecChiaDBPull defines the desired state of an optional chia-db-pull init container
type SpecChiaDBPull struct {
// Enabled defines whether a chia-db-pull init container should run before the chia container.
// Defaults to false.
// +optional
Enabled *bool `json:"enabled,omitempty"`

// Image defines the image to use for the chia-db-pull init container
// +optional
Image *string `json:"image,omitempty"`

// S3Prefix is the S3 URI prefix the chia-db-pull container will download the database from.
// Required when Enabled is true. Mapped to the S3_PREFIX env var.
// +optional
S3Prefix string `json:"s3Prefix,omitempty"`

// Network is the chia network name the database belongs to. Mapped to the NETWORK env var.
// If unset, the operator derives the value from the surrounding chia config: it first looks
// for a "network" key in the ChiaNetwork ConfigMap referenced by spec.chia.chiaNetwork, then
// falls back to spec.chia.network. If neither is set, no NETWORK env var is emitted and
// chia-db-pull will use its own default (mainnet).
// +optional
Network *string `json:"network,omitempty"`

// MinHeight is the minimum block height the downloaded database should be at. Mapped to the MIN_HEIGHT env var.
// +optional
MinHeight *int64 `json:"minHeight,omitempty"`

// AWSCredentialsSecret is the name of a kubernetes Secret in the same namespace whose keys will be loaded
// into the chia-db-pull container as environment variables via envFrom.
// Use this to inject AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY (or any other credentials) without putting them in plaintext.
// +optional
AWSCredentialsSecret *string `json:"awsCredentialsSecret,omitempty"`

// AdditionalEnv contain a list of additional environment variables to be supplied to the chia-db-pull container.
// These variables will be placed at the end of the environment variable list in the resulting container,
// this means they overwrite variables of the same name created by the operator in the container env.
// +optional
AdditionalEnv *[]corev1.EnvVar `json:"additionalEnv,omitempty"`

// Resources defines the compute resources (limits/requests) for the chia-db-pull container.
// +optional
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`

// SecurityContext defines the security context for the chia-db-pull container
// +optional
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
}

// ChiaNodeSpecChia defines the desired state of Chia component configuration
type ChiaNodeSpecChia struct {
CommonSpecChia `json:",inline"`
Expand Down
62 changes: 62 additions & 0 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
Loading