Skip to content

Commit

Permalink
Added support for private docker registry (#300)
Browse files Browse the repository at this point in the history
* Added private registry support
* Removed image verification
* Added test
* Move helper methods to kutil
  • Loading branch information
Dipta Das authored and tamalsaha committed Jan 26, 2018
1 parent 62ec42e commit c3e177c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
3 changes: 3 additions & 0 deletions backup.go
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/appscode/kutil/meta"
cs "github.com/appscode/stash/client/typed/stash/v1alpha1"
"github.com/appscode/stash/pkg/backup"
"github.com/appscode/stash/pkg/docker"
"github.com/appscode/stash/pkg/util"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
Expand All @@ -23,6 +24,7 @@ func NewCmdBackup() *cobra.Command {
Namespace: meta.Namespace(),
ScratchDir: "/tmp",
PodLabelsPath: "/etc/stash/labels",
DockerRegistry: docker.ACRegistry,
ResyncPeriod: 5 * time.Minute,
MaxNumRequeues: 5,
}
Expand Down Expand Up @@ -85,6 +87,7 @@ func NewCmdBackup() *cobra.Command {
cmd.Flags().StringVar(&opt.PushgatewayURL, "pushgateway-url", opt.PushgatewayURL, "URL of Prometheus pushgateway used to cache backup metrics")
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.")
cmd.Flags().BoolVar(&opt.RunViaCron, "run-via-cron", opt.RunViaCron, "Run backup periodically via cron.")
cmd.Flags().StringVar(&opt.DockerRegistry, "docker-registry", opt.DockerRegistry, "Check job image registry.")
cmd.Flags().StringVar(&opt.ImageTag, "image-tag", opt.ImageTag, "Check job image tag.")
cmd.Flags().BoolVar(&opt.EnableRBAC, "enable-rbac", opt.EnableRBAC, "Enable RBAC")

Expand Down
17 changes: 6 additions & 11 deletions run.go
Expand Up @@ -27,9 +27,10 @@ func NewCmdRun() *cobra.Command {
kubeconfigPath string
address string = ":56790"
opts = controller.Options{
SidecarImageTag: stringz.Val(v.Version.Version, "canary"),
ResyncPeriod: 5 * time.Minute,
MaxNumRequeues: 5,
DockerRegistry: docker.ACRegistry,
StashImageTag: stringz.Val(v.Version.Version, "canary"),
ResyncPeriod: 5 * time.Minute,
MaxNumRequeues: 5,
}
scratchDir = "/tmp"
)
Expand All @@ -39,10 +40,6 @@ func NewCmdRun() *cobra.Command {
Short: "Run Stash operator",
DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
if err := docker.CheckDockerImageVersion(docker.ImageOperator, opts.SidecarImageTag); err != nil {
log.Fatalf(`Image %v:%v not found.`, docker.ImageOperator, opts.SidecarImageTag)
}

config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
if err != nil {
log.Fatalln(err)
Expand All @@ -60,11 +57,7 @@ func NewCmdRun() *cobra.Command {
if err != nil {
log.Fatalf("Failed to parse server version, reason: %s\n", err)
}
// check kubectl image
opts.KubectlImageTag = gv.ToMutator().ResetMetadata().ResetPrerelease().ResetPatch().String()
if err := docker.CheckDockerImageVersion(docker.ImageKubectl, opts.KubectlImageTag); err != nil {
log.Fatalf(`Image %v:%v not found.`, docker.ImageKubectl, opts.KubectlImageTag)
}

ctrl := controller.New(kubeClient, crdClient, stashClient, opts)
err = ctrl.Setup()
Expand Down Expand Up @@ -101,6 +94,8 @@ func NewCmdRun() *cobra.Command {
cmd.Flags().BoolVar(&opts.EnableRBAC, "rbac", opts.EnableRBAC, "Enable RBAC for operator")
cmd.Flags().StringVar(&scratchDir, "scratch-dir", scratchDir, "Directory used to store temporary files. Use an `emptyDir` in Kubernetes.")
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.")
cmd.Flags().StringVar(&opts.StashImageTag, "image-tag", opts.StashImageTag, "Image tag for sidecar, init-container, check-job and recovery-job")
cmd.Flags().StringVar(&opts.DockerRegistry, "docker-registry", opts.DockerRegistry, "Docker image registry for sidecar, init-container, check-job, recovery-job and kubectl-job")

return cmd
}

0 comments on commit c3e177c

Please sign in to comment.