mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-25 00:51:48 +00:00
Merge pull request #580 from fluxcd/install-image-controllers
Include image controller config in `flux install`
This commit is contained in:
commit
1f497cac44
14 changed files with 62 additions and 12 deletions
2
.github/workflows/update.yml
vendored
2
.github/workflows/update.yml
vendored
|
|
@ -40,6 +40,8 @@ jobs:
|
||||||
bump_version kustomize-controller
|
bump_version kustomize-controller
|
||||||
bump_version source-controller
|
bump_version source-controller
|
||||||
bump_version notification-controller
|
bump_version notification-controller
|
||||||
|
bump_version image-reflector-controller
|
||||||
|
bump_version image-automation-controller
|
||||||
|
|
||||||
# add missing and remove unused modules
|
# add missing and remove unused modules
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@ var bootstrapCmd = &cobra.Command{
|
||||||
|
|
||||||
var (
|
var (
|
||||||
bootstrapVersion string
|
bootstrapVersion string
|
||||||
bootstrapComponents []string
|
bootstrapDefaultComponents []string
|
||||||
|
bootstrapExtraComponents []string
|
||||||
bootstrapRegistry string
|
bootstrapRegistry string
|
||||||
bootstrapImagePullSecret string
|
bootstrapImagePullSecret string
|
||||||
bootstrapBranch string
|
bootstrapBranch string
|
||||||
|
|
@ -67,8 +68,10 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
bootstrapCmd.PersistentFlags().StringVarP(&bootstrapVersion, "version", "v", defaults.Version,
|
bootstrapCmd.PersistentFlags().StringVarP(&bootstrapVersion, "version", "v", defaults.Version,
|
||||||
"toolkit version")
|
"toolkit version")
|
||||||
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapComponents, "components", defaults.Components,
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapDefaultComponents, "components", defaults.Components,
|
||||||
"list of components, accepts comma-separated values")
|
"list of components, accepts comma-separated values")
|
||||||
|
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapExtraComponents, "components-extra", nil,
|
||||||
|
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
|
||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapRegistry, "registry", "ghcr.io/fluxcd",
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapRegistry, "registry", "ghcr.io/fluxcd",
|
||||||
"container registry where the toolkit images are published")
|
"container registry where the toolkit images are published")
|
||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapImagePullSecret, "image-pull-secret", "",
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapImagePullSecret, "image-pull-secret", "",
|
||||||
|
|
@ -88,13 +91,17 @@ func init() {
|
||||||
rootCmd.AddCommand(bootstrapCmd)
|
rootCmd.AddCommand(bootstrapCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bootstrapComponents() []string {
|
||||||
|
return append(bootstrapDefaultComponents, bootstrapExtraComponents...)
|
||||||
|
}
|
||||||
|
|
||||||
func bootstrapValidate() error {
|
func bootstrapValidate() error {
|
||||||
|
components := bootstrapComponents()
|
||||||
for _, component := range bootstrapRequiredComponents {
|
for _, component := range bootstrapRequiredComponents {
|
||||||
if !utils.ContainsItemString(bootstrapComponents, component) {
|
if !utils.ContainsItemString(components, component) {
|
||||||
return fmt.Errorf("component %s is required", component)
|
return fmt.Errorf("component %s is required", component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +110,7 @@ func generateInstallManifests(targetPath, namespace, tmpDir string, localManifes
|
||||||
BaseURL: localManifests,
|
BaseURL: localManifests,
|
||||||
Version: bootstrapVersion,
|
Version: bootstrapVersion,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Components: bootstrapComponents,
|
Components: bootstrapComponents(),
|
||||||
Registry: bootstrapRegistry,
|
Registry: bootstrapRegistry,
|
||||||
ImagePullSecret: bootstrapImagePullSecret,
|
ImagePullSecret: bootstrapImagePullSecret,
|
||||||
Arch: bootstrapArch.String(),
|
Arch: bootstrapArch.String(),
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
if isInstall {
|
if isInstall {
|
||||||
// apply install manifests
|
// apply install manifests
|
||||||
logger.Actionf("installing components in %s namespace", namespace)
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
if err := applyInstallManifests(ctx, manifest, bootstrapComponents); err != nil {
|
if err := applyInstallManifests(ctx, manifest, bootstrapComponents()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("install completed")
|
logger.Successf("install completed")
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
if isInstall {
|
if isInstall {
|
||||||
// apply install manifests
|
// apply install manifests
|
||||||
logger.Actionf("installing components in %s namespace", namespace)
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
if err := applyInstallManifests(ctx, manifest, bootstrapComponents); err != nil {
|
if err := applyInstallManifests(ctx, manifest, bootstrapComponents()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("install completed")
|
logger.Successf("install completed")
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@ var (
|
||||||
installDryRun bool
|
installDryRun bool
|
||||||
installManifestsPath string
|
installManifestsPath string
|
||||||
installVersion string
|
installVersion string
|
||||||
installComponents []string
|
installDefaultComponents []string
|
||||||
|
installExtraComponents []string
|
||||||
installRegistry string
|
installRegistry string
|
||||||
installImagePullSecret string
|
installImagePullSecret string
|
||||||
installWatchAllNamespaces bool
|
installWatchAllNamespaces bool
|
||||||
|
|
@ -72,8 +73,10 @@ func init() {
|
||||||
"only print the object that would be applied")
|
"only print the object that would be applied")
|
||||||
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaults.Version,
|
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaults.Version,
|
||||||
"toolkit version")
|
"toolkit version")
|
||||||
installCmd.Flags().StringSliceVar(&installComponents, "components", defaults.Components,
|
installCmd.Flags().StringSliceVar(&installDefaultComponents, "components", defaults.Components,
|
||||||
"list of components, accepts comma-separated values")
|
"list of components, accepts comma-separated values")
|
||||||
|
installCmd.Flags().StringSliceVar(&installExtraComponents, "components-extra", nil,
|
||||||
|
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
|
||||||
installCmd.Flags().StringVar(&installManifestsPath, "manifests", "", "path to the manifest directory")
|
installCmd.Flags().StringVar(&installManifestsPath, "manifests", "", "path to the manifest directory")
|
||||||
installCmd.Flags().MarkHidden("manifests")
|
installCmd.Flags().MarkHidden("manifests")
|
||||||
installCmd.Flags().StringVar(&installRegistry, "registry", defaults.Registry,
|
installCmd.Flags().StringVar(&installRegistry, "registry", defaults.Registry,
|
||||||
|
|
@ -103,11 +106,13 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
logger.Generatef("generating manifests")
|
logger.Generatef("generating manifests")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
components := append(installDefaultComponents, installExtraComponents...)
|
||||||
|
|
||||||
opts := install.Options{
|
opts := install.Options{
|
||||||
BaseURL: installManifestsPath,
|
BaseURL: installManifestsPath,
|
||||||
Version: installVersion,
|
Version: installVersion,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Components: installComponents,
|
Components: components,
|
||||||
Registry: installRegistry,
|
Registry: installRegistry,
|
||||||
ImagePullSecret: installImagePullSecret,
|
ImagePullSecret: installImagePullSecret,
|
||||||
Arch: installArch.String(),
|
Arch: installArch.String(),
|
||||||
|
|
@ -137,7 +142,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
} else if installExport {
|
} else if installExport {
|
||||||
fmt.Println("---")
|
fmt.Println("---")
|
||||||
fmt.Println("# GitOps Toolkit revision", installVersion)
|
fmt.Println("# GitOps Toolkit revision", installVersion)
|
||||||
fmt.Println("# Components:", strings.Join(installComponents, ","))
|
fmt.Println("# Components:", strings.Join(components, ","))
|
||||||
fmt.Print(manifest.Content)
|
fmt.Print(manifest.Content)
|
||||||
fmt.Println("---")
|
fmt.Println("---")
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -167,7 +172,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Waitingf("verifying installation")
|
logger.Waitingf("verifying installation")
|
||||||
for _, deployment := range installComponents {
|
for _, deployment := range components {
|
||||||
kubectlArgs = []string{"-n", namespace, "rollout", "status", "deployment", deployment, "--timeout", timeout.String()}
|
kubectlArgs = []string{"-n", namespace, "rollout", "status", "deployment", deployment, "--timeout", timeout.String()}
|
||||||
if _, err := utils.ExecKubectlCommand(ctx, applyOutput, kubeconfig, kubecontext, kubectlArgs...); err != nil {
|
if _, err := utils.ExecKubectlCommand(ctx, applyOutput, kubeconfig, kubecontext, kubectlArgs...); err != nil {
|
||||||
return fmt.Errorf("install failed")
|
return fmt.Errorf("install failed")
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ The bootstrap sub-commands bootstrap the toolkit components on the targeted Git
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||||
--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])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
-h, --help help for bootstrap
|
-h, --help help for bootstrap
|
||||||
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--log-level logLevel log level, available options are: (debug, info, error) (default info)
|
--log-level logLevel log level, available options are: (debug, info, error) (default info)
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ flux bootstrap github [flags]
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||||
--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])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--context string kubernetes context to use
|
--context string kubernetes context to use
|
||||||
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ flux bootstrap gitlab [flags]
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
--branch string default branch (for GitHub this must match the default branch setting for the organization) (default "main")
|
||||||
--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])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--context string kubernetes context to use
|
--context string kubernetes context to use
|
||||||
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ flux install [flags]
|
||||||
```
|
```
|
||||||
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
--arch arch cluster architecture, available options are: (amd64, arm, arm64) (default amd64)
|
||||||
--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])
|
||||||
|
--components-extra strings list of components in addition to those supplied or defaulted, accepts comma-separated values
|
||||||
--dry-run only print the object that would be applied
|
--dry-run only print the object that would be applied
|
||||||
--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
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- https://github.com/fluxcd/image-automation-controller/archive/v0.1.0.zip//image-automation-controller-0.1.0/config/crd
|
||||||
|
- https://github.com/fluxcd/image-automation-controller/archive/v0.1.0.zip//image-automation-controller-0.1.0/config/manager
|
||||||
|
patchesJson6902:
|
||||||
|
- target:
|
||||||
|
group: apps
|
||||||
|
version: v1
|
||||||
|
kind: Deployment
|
||||||
|
name: image-automation-controller
|
||||||
|
path: patch.yaml
|
||||||
3
manifests/bases/image-automation-controller/patch.yaml
Normal file
3
manifests/bases/image-automation-controller/patch.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
- op: add
|
||||||
|
path: /spec/template/spec/containers/0/args/0
|
||||||
|
value: --events-addr=http://notification-controller/
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- https://github.com/fluxcd/image-reflector-controller/archive/v0.1.0.zip//image-reflector-controller-0.1.0/config/crd
|
||||||
|
- https://github.com/fluxcd/image-reflector-controller/archive/v0.1.0.zip//image-reflector-controller-0.1.0/config/manager
|
||||||
|
patchesJson6902:
|
||||||
|
- target:
|
||||||
|
group: apps
|
||||||
|
version: v1
|
||||||
|
kind: Deployment
|
||||||
|
name: image-reflector-controller
|
||||||
|
path: patch.yaml
|
||||||
3
manifests/bases/image-reflector-controller/patch.yaml
Normal file
3
manifests/bases/image-reflector-controller/patch.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
- op: add
|
||||||
|
path: /spec/template/spec/containers/0/args/0
|
||||||
|
value: --events-addr=http://notification-controller/
|
||||||
|
|
@ -7,6 +7,8 @@ resources:
|
||||||
- ../bases/kustomize-controller
|
- ../bases/kustomize-controller
|
||||||
- ../bases/notification-controller
|
- ../bases/notification-controller
|
||||||
- ../bases/helm-controller
|
- ../bases/helm-controller
|
||||||
|
- ../bases/image-reflector-controller
|
||||||
|
- ../bases/image-automation-controller
|
||||||
- ../rbac
|
- ../rbac
|
||||||
- ../policies
|
- ../policies
|
||||||
transformers:
|
transformers:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue