Skip to content

Commit

Permalink
Add bootstrapPeers field to ChiaSeeders (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
Starttoaster authored Nov 19, 2024
1 parent d0e46fe commit 914f8c7
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 9 deletions.
20 changes: 20 additions & 0 deletions DEPRECATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Deprecations

## ChiaSeeder

### bootstrapPeer

Deprecated in: 0.12.5
Expected to be removed in: 1.0.0

The `bootstrapPeer` API field was deprecated in favor of `bootstrapPeers`. The latter being the preferred way to specify multiple bootstrap peers for a seeder installation, which still allows for specifying a single peer.

Switch to bootstrapPeers by specifying a yaml string list instead of a string:

```yaml
spec:
chia:
# bootstrapPeer: "mainnet-node.chia.svc.cluster.local"
bootstrapPeers:
- "mainnet-node.chia.svc.cluster.local"
```
15 changes: 10 additions & 5 deletions api/v1/chiaseeder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ type ChiaSeederSpec struct {
type ChiaSeederSpecChia struct {
CommonSpecChia `json:",inline"`

// BootstrapPeer a peer to bootstrap the seeder's peer database
// BootstrapPeer a peer to bootstrap the seeder's peer database.
// DEPRECATED: Use BootstrapPeers instead.
// +optional
BootstrapPeer *string `json:"bootstrapPeer"`
BootstrapPeer *string `json:"bootstrapPeer,omitempty"`

// BootstrapPeers a list of peers to bootstrap the seeder's peer database
// +optional
BootstrapPeers *[]string `json:"bootstrapPeers,omitempty"`

// MinimumHeight only consider nodes synced at least to this height
// +optional
MinimumHeight *uint64 `json:"minimumHeight"`
MinimumHeight *uint64 `json:"minimumHeight,omitempty"`

// DomainName the name of the NS record for your server with a trailing period. (ex. "seeder.example.com.")
DomainName string `json:"domainName"`
Expand All @@ -48,11 +53,11 @@ type ChiaSeederSpecChia struct {

// CASecretName is the name of the secret that contains the CA crt and key. Not required for seeders.
// +optional
CASecretName *string `json:"caSecretName"`
CASecretName *string `json:"caSecretName,omitempty"`

// TTL field on DNS records that controls the length of time that a record is considered valid
// +optional
TTL *uint32 `json:"ttl"`
TTL *uint32 `json:"ttl,omitempty"`
}

// ChiaSeederStatus defines the observed state of ChiaSeeder
Expand Down
9 changes: 9 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.

11 changes: 9 additions & 2 deletions config/crd/bases/k8s.chia.net_chiaseeders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,16 @@ spec:
type: string
type: object
bootstrapPeer:
description: BootstrapPeer a peer to bootstrap the seeder's peer
database
description: |-
BootstrapPeer a peer to bootstrap the seeder's peer database.
DEPRECATED: Use BootstrapPeers instead.
type: string
bootstrapPeers:
description: BootstrapPeers a list of peers to bootstrap the seeder's
peer database
items:
type: string
type: array
caSecretName:
description: CASecretName is the name of the secret that contains
the CA crt and key. Not required for seeders.
Expand Down
3 changes: 2 additions & 1 deletion docs/chiaseeder.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Some of Chia's configuration can be changed from within the CR.
spec:
chia:
minimumHeight: 240000 # Only consider nodes synced at least to this height
bootstrapPeer: "mainnet-node.chia.svc.cluster.local" # Peers used for the initial crawler run to find peers
bootstrapPeers:
- "mainnet-node.chia.svc.cluster.local" # Peers used for the initial crawler run to find peers
ttl: 900 # field on DNS records that controls the length of time that a record is considered valid
```
Expand Down
8 changes: 7 additions & 1 deletion internal/controller/chiaseeder/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package chiaseeder

import (
"fmt"
"strings"

"github.com/chia-network/chia-operator/internal/controller/common/kube"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -85,7 +86,12 @@ func getChiaEnv(seeder k8schianetv1.ChiaSeeder, networkData *map[string]string)
})

// seeder_bootstrap_peers env var
if seeder.Spec.ChiaConfig.BootstrapPeer != nil {
if seeder.Spec.ChiaConfig.BootstrapPeers != nil {
env = append(env, corev1.EnvVar{
Name: "seeder_bootstrap_peers",
Value: strings.Join(*seeder.Spec.ChiaConfig.BootstrapPeers, ","),
})
} else if seeder.Spec.ChiaConfig.BootstrapPeer != nil {
env = append(env, corev1.EnvVar{
Name: "seeder_bootstrap_peers",
Value: *seeder.Spec.ChiaConfig.BootstrapPeer,
Expand Down

0 comments on commit 914f8c7

Please sign in to comment.