Skip to content

Commit

Permalink
feat: add capability to override docker registries (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag authored Oct 31, 2023
1 parent a34f20b commit d61b21b
Show file tree
Hide file tree
Showing 60 changed files with 3,856 additions and 7 deletions.
347 changes: 347 additions & 0 deletions components/fctl/membershipclient/go.sum

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions components/operator/apis/stack/v1beta3/configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta3

import (
"fmt"
"reflect"
"strings"

Expand Down Expand Up @@ -116,6 +117,10 @@ type MetricsSpec struct {
Otlp *OtlpSpec `json:"otlp,omitempty"`
}

type RegistryConfig struct {
Endpoint string `json:"endpoint"`
}

type ConfigurationSpec struct {
Services ConfigurationServicesSpec `json:"services"`
Broker Broker `json:"broker"`
Expand All @@ -128,6 +133,8 @@ type ConfigurationSpec struct {
// LightMode is experimental and indicate we want monopods
// +optional
LightMode bool `json:"light,omitempty"`
// +optional
Registries map[string]RegistryConfig `json:"registries,omitempty"`
}

func (in *ConfigurationSpec) GetServices() []string {
Expand Down Expand Up @@ -159,6 +166,26 @@ func (c Configuration) Validate() error {
return nil
}

func (c *Configuration) ResolveImage(image string) string {
parts := strings.Split(image, ":")
repository := parts[0]
repositoryParts := strings.SplitN(repository, "/", 2)
var (
registry, path string
)
if len(repositoryParts) == 1 {
registry = "docker.io"
path = repository
} else {
registry = repositoryParts[0]
path = repositoryParts[1]
}
if config, ok := c.Spec.Registries[registry]; ok && config.Endpoint != "" {
return fmt.Sprintf("%s/%s:%s", config.Endpoint, path, parts[1])
}
return image
}

//+kubebuilder:object:root=true

// ConfigurationList contains a list of Configuration
Expand Down
22 changes: 22 additions & 0 deletions components/operator/apis/stack/v1beta3/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -4208,6 +4208,15 @@ spec:
type: object
type: object
type: object
registries:
additionalProperties:
properties:
endpoint:
type: string
required:
- endpoint
type: object
type: object
services:
description: ConfigurationServicesSpec define all existing services
for a stack. Fields order is important. For example, auth must be
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: stack.formance.com/v1beta3
kind: Configuration
metadata:
name: default
spec:
registries:
ghcr.io:
endpoint: localhost:5000
broker:
kafka:
brokers:
- kafka1:1234
- kafka2:1234
monitoring:
traces:
otlp:
endpoint: localhost
insecure: true
mode: grpc
port: 4317
services:
auth:
postgres:
disableSSLMode: true
host: localhost
password: root
port: 5432
username: root
control: {}
ledger:
postgres:
disableSSLMode: true
host: localhost
password: root
port: 5432
username: root
orchestration:
postgres:
disableSSLMode: true
host: localhost
password: root
port: 5432
username: root
payments:
encryptionKey:
postgres:
disableSSLMode: true
host: localhost
password: root
port: 5432
username: root
search:
batching:
count:
period:
elasticSearch:
host: elasticsearch
pathPrefix: ''
port: 9200
scheme: http
stargate:
wallets:
webhooks:
postgres:
disableSSLMode: true
host: localhost
password: root
port: 5432
username: root
temporal:
address:
namespace:
tls:
crt:
key:
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v1
data:
config.yaml: |
clients:
- public: false
description: null
redirectUris:
- http://example.net/auth/login
PostLogoutRedirectUris:
- http://example.net/auth/destroy
scopes:
- openid
- profile
- email
- offline
id: control
secrets:
- mocked-secret
- public: false
description: null
redirectUris: []
PostLogoutRedirectUris: []
scopes:
- openid
id: orchestration
secrets:
- mocked-secret
- public: false
description: null
redirectUris: []
PostLogoutRedirectUris: []
scopes:
- openid
id: wallets
secrets:
- mocked-secret
kind: ConfigMap
metadata:
labels:
stack: "true"
name: auth-config
namespace: multipod-latest-with-custom-registry
Loading

1 comment on commit d61b21b

@vercel
Copy link

@vercel vercel bot commented on d61b21b Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.