Add image pull secret arg to install/bootstrap
This commit is contained in:
@@ -48,6 +48,7 @@ var (
|
|||||||
bootstrapVersion string
|
bootstrapVersion string
|
||||||
bootstrapComponents []string
|
bootstrapComponents []string
|
||||||
bootstrapRegistry string
|
bootstrapRegistry string
|
||||||
|
bootstrapImagePullSecret string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -64,6 +65,8 @@ func init() {
|
|||||||
"list of components, accepts comma-separated values")
|
"list of components, accepts comma-separated values")
|
||||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapRegistry, "registry", "docker.io/fluxcd",
|
bootstrapCmd.PersistentFlags().StringVar(&bootstrapRegistry, "registry", "docker.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", "",
|
||||||
|
"Kubernetes secret name used for pulling the toolkit images from a private registry")
|
||||||
rootCmd.AddCommand(bootstrapCmd)
|
rootCmd.AddCommand(bootstrapCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +78,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, bootstrapRegistry, tkDir); err != nil {
|
if err := genInstallManifests(bootstrapVersion, namespace, bootstrapComponents, bootstrapRegistry, bootstrapImagePullSecret, tkDir); err != nil {
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
return "", fmt.Errorf("generating manifests failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ var (
|
|||||||
installVersion string
|
installVersion string
|
||||||
installComponents []string
|
installComponents []string
|
||||||
installRegistry string
|
installRegistry string
|
||||||
|
installImagePullSecret string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -75,6 +76,8 @@ func init() {
|
|||||||
"path to the manifest directory, dev only")
|
"path to the manifest directory, dev only")
|
||||||
installCmd.Flags().StringVar(&installRegistry, "registry", "docker.io/fluxcd",
|
installCmd.Flags().StringVar(&installRegistry, "registry", "docker.io/fluxcd",
|
||||||
"container registry where the toolkit images are published")
|
"container registry where the toolkit images are published")
|
||||||
|
installCmd.Flags().StringVar(&installImagePullSecret, "image-pull-secret", "",
|
||||||
|
"Kubernetes secret name used for pulling the toolkit images from a private registry")
|
||||||
rootCmd.AddCommand(installCmd)
|
rootCmd.AddCommand(installCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +103,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, installRegistry, tmpDir)
|
err = genInstallManifests(installVersion, namespace, installComponents, installRegistry, installImagePullSecret, tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("install failed: %w", err)
|
return fmt.Errorf("install failed: %w", err)
|
||||||
}
|
}
|
||||||
@@ -252,6 +255,10 @@ spec:
|
|||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/arch: amd64
|
kubernetes.io/arch: amd64
|
||||||
kubernetes.io/os: linux
|
kubernetes.io/os: linux
|
||||||
|
{{- if .ImagePullSecret }}
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: {{.ImagePullSecret}}
|
||||||
|
{{- end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
func downloadManifests(version string, tmpDir string) error {
|
func downloadManifests(version string, tmpDir string) error {
|
||||||
@@ -288,7 +295,7 @@ func downloadManifests(version string, tmpDir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func genInstallManifests(version string, namespace string, components []string, registry string, tmpDir string) error {
|
func genInstallManifests(version string, namespace string, components []string, registry, imagePullSecret, 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)
|
||||||
@@ -300,12 +307,14 @@ func genInstallManifests(version string, namespace string, components []string,
|
|||||||
Components []string
|
Components []string
|
||||||
EventsAddr string
|
EventsAddr string
|
||||||
Registry string
|
Registry string
|
||||||
|
ImagePullSecret string
|
||||||
}{
|
}{
|
||||||
Version: version,
|
Version: version,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Components: components,
|
Components: components,
|
||||||
EventsAddr: eventsAddr,
|
EventsAddr: eventsAddr,
|
||||||
Registry: registry,
|
Registry: registry,
|
||||||
|
ImagePullSecret: imagePullSecret,
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--registry string container registry where the toolkit images are published (default "docker.io/fluxcd")
|
--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")
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -55,6 +55,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])
|
||||||
|
--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")
|
||||||
--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")
|
--registry string container registry where the toolkit images are published (default "docker.io/fluxcd")
|
||||||
|
|||||||
@@ -51,6 +51,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])
|
||||||
|
--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")
|
||||||
--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")
|
--registry string container registry where the toolkit images are published (default "docker.io/fluxcd")
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ tk install [flags]
|
|||||||
--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
|
||||||
|
--image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry
|
||||||
--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")
|
--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")
|
||||||
|
|||||||
Reference in New Issue
Block a user