Skip to content

Commit

Permalink
Add support for chia-docker source_ref variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Starttoaster committed Sep 11, 2024
1 parent c1bc799 commit 1d8fc00
Show file tree
Hide file tree
Showing 19 changed files with 125 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v1/chiacommon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ type CommonSpecChia struct {
// +optional
Timezone *string `json:"timezone,omitempty"`

// SourceRef is set to the desired ref of the chia-blockchain repository to install from. Defaults to unset (uses the installation already in the chia image.)
// +optional
SourceRef *string `json:"sourceRef,omitempty"`

// LogLevel is set to the desired chia config log_level
// +optional
LogLevel *string `json:"logLevel,omitempty"`
Expand Down
5 changes: 5 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.

5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chiacrawlers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chiafarmers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chiaharvesters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chiaintroducers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chianodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chiaseeders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chiatimelords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/k8s.chia.net_chiawallets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,11 @@ spec:
SelfHostname defines the bind address of chia services in the container
Setting to `0.0.0.0` binds chia services to all interfaces
type: string
sourceRef:
description: SourceRef is set to the desired ref of the chia-blockchain
repository to install from. Defaults to unset (uses the installation
already in the chia image.)
type: string
startupProbe:
description: StartupProbe indicates that the Pod has successfully
initialized.
Expand Down
12 changes: 12 additions & 0 deletions docs/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ spec:
dnsIntroducerAddress: "dns-introducer.default.svc.cluster.local" # Sets the DNS introducer address used in the chia config file.
```

### Install chia from a specific ref

You can select a specific ref (commit sha or branch) from the chia-blockchain repository to install chia from. This is unnecessary the majority of the time as the image has a chia installation by default, but this may be useful for testing specific versions of chia:

```yaml
spec:
chia:
sourceRef: "a6a27bfe8e8d3e3db16701e7a33182ac11ce0723" # commit sha of github.com/Chia-Network/chia-blockchain to install from
```

Note that if you use this configuration, the tag of the chia image running in your Pods may still specify a version of chia-blockchain, but is no longer the version of chia installed in the image.

## Chia container resource requests and limits

You can set resource requests and limits for the chia container deployed from a custom resource with the following (note that these are just example values, and not to be taken as recommendations for your deployments):
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chiacrawler/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ func getChiaEnv(crawler k8schianetv1.ChiaCrawler) []corev1.EnvVar {
})
}

// source_ref env var
if crawler.Spec.ChiaConfig.SourceRef != nil && *crawler.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *crawler.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if crawler.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chiafarmer/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func getChiaEnv(farmer k8schianetv1.ChiaFarmer) []corev1.EnvVar {
})
}

// source_ref env var
if farmer.Spec.ChiaConfig.SourceRef != nil && *farmer.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *farmer.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if farmer.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chiaharvester/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ func getChiaEnv(harvester k8schianetv1.ChiaHarvester) []corev1.EnvVar {
})
}

// source_ref env var
if harvester.Spec.ChiaConfig.SourceRef != nil && *harvester.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *harvester.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if harvester.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chiaintroducer/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ func getChiaEnv(introducer k8schianetv1.ChiaIntroducer) []corev1.EnvVar {
})
}

// source_ref env var
if introducer.Spec.ChiaConfig.SourceRef != nil && *introducer.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *introducer.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if introducer.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chianode/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ func getChiaEnv(ctx context.Context, node k8schianetv1.ChiaNode) []corev1.EnvVar
})
}

// source_ref env var
if node.Spec.ChiaConfig.SourceRef != nil && *node.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *node.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if node.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chiaseeder/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ func getChiaEnv(seeder k8schianetv1.ChiaSeeder) []corev1.EnvVar {
})
}

// source_ref env var
if seeder.Spec.ChiaConfig.SourceRef != nil && *seeder.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *seeder.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if seeder.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chiatimelord/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ func getChiaEnv(tl k8schianetv1.ChiaTimelord) []corev1.EnvVar {
})
}

// source_ref env var
if tl.Spec.ChiaConfig.SourceRef != nil && *tl.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *tl.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if tl.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/chiawallet/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ func getChiaEnv(ctx context.Context, wallet k8schianetv1.ChiaWallet) []corev1.En
})
}

// source_ref env var
if wallet.Spec.ChiaConfig.SourceRef != nil && *wallet.Spec.ChiaConfig.SourceRef != "" {
env = append(env, corev1.EnvVar{
Name: "source_ref",
Value: *wallet.Spec.ChiaConfig.SourceRef,
})
}

// self_hostname env var
if wallet.Spec.ChiaConfig.SelfHostname != nil {
env = append(env, corev1.EnvVar{
Expand Down

0 comments on commit 1d8fc00

Please sign in to comment.