mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-22 15:41:47 +00:00
Add container registry option to install/bootstrap
This commit is contained in:
parent
efb39d6fc6
commit
57a1dbfc6d
6 changed files with 28 additions and 8 deletions
|
|
@ -47,6 +47,7 @@ var bootstrapCmd = &cobra.Command{
|
||||||
var (
|
var (
|
||||||
bootstrapVersion string
|
bootstrapVersion string
|
||||||
bootstrapComponents []string
|
bootstrapComponents []string
|
||||||
|
bootstrapRegistry string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -61,7 +62,8 @@ func init() {
|
||||||
"toolkit version")
|
"toolkit version")
|
||||||
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapComponents, "components", defaultComponents,
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapComponents, "components", defaultComponents,
|
||||||
"list of components, accepts comma-separated values")
|
"list of components, accepts comma-separated values")
|
||||||
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapRegistry, "registry", "docker.io/fluxcd",
|
||||||
|
"container registry where the toolkit images are published")
|
||||||
rootCmd.AddCommand(bootstrapCmd)
|
rootCmd.AddCommand(bootstrapCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +75,7 @@ func generateInstallManifests(targetPath, namespace, tmpDir string) (string, err
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
return "", fmt.Errorf("generating manifests failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := genInstallManifests(bootstrapVersion, namespace, bootstrapComponents, tkDir); err != nil {
|
if err := genInstallManifests(bootstrapVersion, namespace, bootstrapComponents, bootstrapRegistry, tkDir); err != nil {
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
return "", fmt.Errorf("generating manifests failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ var (
|
||||||
installManifestsPath string
|
installManifestsPath string
|
||||||
installVersion string
|
installVersion string
|
||||||
installComponents []string
|
installComponents []string
|
||||||
|
installRegistry string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -70,8 +71,10 @@ func init() {
|
||||||
"toolkit version")
|
"toolkit version")
|
||||||
installCmd.Flags().StringSliceVar(&installComponents, "components", defaultComponents,
|
installCmd.Flags().StringSliceVar(&installComponents, "components", defaultComponents,
|
||||||
"list of components, accepts comma-separated values")
|
"list of components, accepts comma-separated values")
|
||||||
installCmd.Flags().StringVarP(&installManifestsPath, "manifests", "", "",
|
installCmd.Flags().StringVar(&installManifestsPath, "manifests", "",
|
||||||
"path to the manifest directory, dev only")
|
"path to the manifest directory, dev only")
|
||||||
|
installCmd.Flags().StringVar(&installRegistry, "registry", "docker.io/fluxcd",
|
||||||
|
"container registry where the toolkit images are published")
|
||||||
rootCmd.AddCommand(installCmd)
|
rootCmd.AddCommand(installCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,7 +100,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
logger.Generatef("generating manifests")
|
logger.Generatef("generating manifests")
|
||||||
}
|
}
|
||||||
if kustomizePath == "" {
|
if kustomizePath == "" {
|
||||||
err = genInstallManifests(installVersion, namespace, installComponents, tmpDir)
|
err = genInstallManifests(installVersion, namespace, installComponents, installRegistry, tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("install failed: %w", err)
|
return fmt.Errorf("install failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -185,6 +188,7 @@ fieldSpecs:
|
||||||
|
|
||||||
var kustomizationTmpl = `---
|
var kustomizationTmpl = `---
|
||||||
{{- $eventsAddr := .EventsAddr }}
|
{{- $eventsAddr := .EventsAddr }}
|
||||||
|
{{- $registry := .Registry }}
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
namespace: {{.Namespace}}
|
namespace: {{.Namespace}}
|
||||||
|
|
@ -206,19 +210,27 @@ patches:
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
||||||
patchesJson6902:
|
patchesJson6902:
|
||||||
{{- range $i, $v := .Components }}
|
{{- range $i, $component := .Components }}
|
||||||
{{- if ne $v "notification-controller" }}
|
{{- if ne $component "notification-controller" }}
|
||||||
- target:
|
- target:
|
||||||
group: apps
|
group: apps
|
||||||
version: v1
|
version: v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: {{$v}}
|
name: {{$component}}
|
||||||
patch: |-
|
patch: |-
|
||||||
- op: replace
|
- op: replace
|
||||||
path: /spec/template/spec/containers/0/args/0
|
path: /spec/template/spec/containers/0/args/0
|
||||||
value: --events-addr={{$eventsAddr}}
|
value: --events-addr={{$eventsAddr}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if $registry }}
|
||||||
|
images:
|
||||||
|
{{- range $i, $component := .Components }}
|
||||||
|
- name: fluxcd/{{$component}}
|
||||||
|
newName: {{$registry}}/{{$component}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
var kustomizationRolesTmpl = `---
|
var kustomizationRolesTmpl = `---
|
||||||
|
|
@ -276,7 +288,7 @@ func downloadManifests(version string, tmpDir string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func genInstallManifests(version string, namespace string, components []string, tmpDir string) error {
|
func genInstallManifests(version string, namespace string, components []string, registry string, tmpDir string) error {
|
||||||
eventsAddr := ""
|
eventsAddr := ""
|
||||||
if utils.containsItemString(components, defaultNotification) {
|
if utils.containsItemString(components, defaultNotification) {
|
||||||
eventsAddr = fmt.Sprintf("http://%s/", defaultNotification)
|
eventsAddr = fmt.Sprintf("http://%s/", defaultNotification)
|
||||||
|
|
@ -287,11 +299,13 @@ func genInstallManifests(version string, namespace string, components []string,
|
||||||
Namespace string
|
Namespace string
|
||||||
Components []string
|
Components []string
|
||||||
EventsAddr string
|
EventsAddr string
|
||||||
|
Registry string
|
||||||
}{
|
}{
|
||||||
Version: version,
|
Version: version,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Components: components,
|
Components: components,
|
||||||
EventsAddr: eventsAddr,
|
EventsAddr: eventsAddr,
|
||||||
|
Registry: registry,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := downloadManifests(version, tmpDir); err != nil {
|
if err := downloadManifests(version, tmpDir); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ The bootstrap sub-commands bootstrap the toolkit components on the targeted Git
|
||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
-h, --help help for bootstrap
|
-h, --help help for bootstrap
|
||||||
|
--registry string container registry where the toolkit images are published (default "docker.io/fluxcd")
|
||||||
-v, --version string toolkit version (default "latest")
|
-v, --version string toolkit version (default "latest")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ tk bootstrap github [flags]
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
|
--registry string container registry where the toolkit images are published (default "docker.io/fluxcd")
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--verbose print generated objects
|
--verbose print generated objects
|
||||||
-v, --version string toolkit version (default "latest")
|
-v, --version string toolkit version (default "latest")
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ tk bootstrap gitlab [flags]
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
--namespace string the namespace scope for this operation (default "gitops-system")
|
--namespace string the namespace scope for this operation (default "gitops-system")
|
||||||
|
--registry string container registry where the toolkit images are published (default "docker.io/fluxcd")
|
||||||
--timeout duration timeout for this operation (default 5m0s)
|
--timeout duration timeout for this operation (default 5m0s)
|
||||||
--verbose print generated objects
|
--verbose print generated objects
|
||||||
-v, --version string toolkit version (default "latest")
|
-v, --version string toolkit version (default "latest")
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ tk install [flags]
|
||||||
--export write the install manifests to stdout and exit
|
--export write the install manifests to stdout and exit
|
||||||
-h, --help help for install
|
-h, --help help for install
|
||||||
--manifests string path to the manifest directory, dev only
|
--manifests string path to the manifest directory, dev only
|
||||||
|
--registry string container registry where the toolkit images are published (default "docker.io/fluxcd")
|
||||||
-v, --version string toolkit version (default "latest")
|
-v, --version string toolkit version (default "latest")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue