Skip to content

Commit c3e177c

Browse files
Dipta Dastamalsaha
authored andcommitted
Added support for private docker registry (#300)
* Added private registry support * Removed image verification * Added test * Move helper methods to kutil
1 parent 62ec42e commit c3e177c

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

backup.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/appscode/kutil/meta"
1010
cs "github.com/appscode/stash/client/typed/stash/v1alpha1"
1111
"github.com/appscode/stash/pkg/backup"
12+
"github.com/appscode/stash/pkg/docker"
1213
"github.com/appscode/stash/pkg/util"
1314
"github.com/spf13/cobra"
1415
"k8s.io/client-go/kubernetes"
@@ -23,6 +24,7 @@ func NewCmdBackup() *cobra.Command {
2324
Namespace: meta.Namespace(),
2425
ScratchDir: "/tmp",
2526
PodLabelsPath: "/etc/stash/labels",
27+
DockerRegistry: docker.ACRegistry,
2628
ResyncPeriod: 5 * time.Minute,
2729
MaxNumRequeues: 5,
2830
}
@@ -85,6 +87,7 @@ func NewCmdBackup() *cobra.Command {
8587
cmd.Flags().StringVar(&opt.PushgatewayURL, "pushgateway-url", opt.PushgatewayURL, "URL of Prometheus pushgateway used to cache backup metrics")
8688
cmd.Flags().DurationVar(&opt.ResyncPeriod, "resync-period", opt.ResyncPeriod, "If non-zero, will re-list this often. Otherwise, re-list will be delayed aslong as possible (until the upstream source closes the watch or times out.")
8789
cmd.Flags().BoolVar(&opt.RunViaCron, "run-via-cron", opt.RunViaCron, "Run backup periodically via cron.")
90+
cmd.Flags().StringVar(&opt.DockerRegistry, "docker-registry", opt.DockerRegistry, "Check job image registry.")
8891
cmd.Flags().StringVar(&opt.ImageTag, "image-tag", opt.ImageTag, "Check job image tag.")
8992
cmd.Flags().BoolVar(&opt.EnableRBAC, "enable-rbac", opt.EnableRBAC, "Enable RBAC")
9093

run.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ func NewCmdRun() *cobra.Command {
2727
kubeconfigPath string
2828
address string = ":56790"
2929
opts = controller.Options{
30-
SidecarImageTag: stringz.Val(v.Version.Version, "canary"),
31-
ResyncPeriod: 5 * time.Minute,
32-
MaxNumRequeues: 5,
30+
DockerRegistry: docker.ACRegistry,
31+
StashImageTag: stringz.Val(v.Version.Version, "canary"),
32+
ResyncPeriod: 5 * time.Minute,
33+
MaxNumRequeues: 5,
3334
}
3435
scratchDir = "/tmp"
3536
)
@@ -39,10 +40,6 @@ func NewCmdRun() *cobra.Command {
3940
Short: "Run Stash operator",
4041
DisableAutoGenTag: true,
4142
Run: func(cmd *cobra.Command, args []string) {
42-
if err := docker.CheckDockerImageVersion(docker.ImageOperator, opts.SidecarImageTag); err != nil {
43-
log.Fatalf(`Image %v:%v not found.`, docker.ImageOperator, opts.SidecarImageTag)
44-
}
45-
4643
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
4744
if err != nil {
4845
log.Fatalln(err)
@@ -60,11 +57,7 @@ func NewCmdRun() *cobra.Command {
6057
if err != nil {
6158
log.Fatalf("Failed to parse server version, reason: %s\n", err)
6259
}
63-
// check kubectl image
6460
opts.KubectlImageTag = gv.ToMutator().ResetMetadata().ResetPrerelease().ResetPatch().String()
65-
if err := docker.CheckDockerImageVersion(docker.ImageKubectl, opts.KubectlImageTag); err != nil {
66-
log.Fatalf(`Image %v:%v not found.`, docker.ImageKubectl, opts.KubectlImageTag)
67-
}
6861

6962
ctrl := controller.New(kubeClient, crdClient, stashClient, opts)
7063
err = ctrl.Setup()
@@ -101,6 +94,8 @@ func NewCmdRun() *cobra.Command {
10194
cmd.Flags().BoolVar(&opts.EnableRBAC, "rbac", opts.EnableRBAC, "Enable RBAC for operator")
10295
cmd.Flags().StringVar(&scratchDir, "scratch-dir", scratchDir, "Directory used to store temporary files. Use an `emptyDir` in Kubernetes.")
10396
cmd.Flags().DurationVar(&opts.ResyncPeriod, "resync-period", opts.ResyncPeriod, "If non-zero, will re-list this often. Otherwise, re-list will be delayed aslong as possible (until the upstream source closes the watch or times out.")
97+
cmd.Flags().StringVar(&opts.StashImageTag, "image-tag", opts.StashImageTag, "Image tag for sidecar, init-container, check-job and recovery-job")
98+
cmd.Flags().StringVar(&opts.DockerRegistry, "docker-registry", opts.DockerRegistry, "Docker image registry for sidecar, init-container, check-job, recovery-job and kubectl-job")
10499

105100
return cmd
106101
}

0 commit comments

Comments
 (0)