Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to set default repo from profile #2317

Open
saturnism opened this issue Jun 22, 2019 · 21 comments
Open

ability to set default repo from profile #2317

saturnism opened this issue Jun 22, 2019 · 21 comments

Comments

@saturnism
Copy link

currently, the default repo can be associated w/ a kubecontext and is stored in $HOME/.skaffold/config. It would be useful if the default repo is configured from skaffold profile.

@balopat
Copy link
Contributor

balopat commented Jun 22, 2019

cc @tejal29

@saturnism
Copy link
Author

quick ping on this one. We are starting a new project, and the global default repo is not helping us to expand easily.

@zhuzeng
Copy link

zhuzeng commented Sep 11, 2019

Yes the global default repo is definitely causing us some debugging time and only find out it's not any mis-configurations in the project itself.

@tejal29
Copy link
Member

tejal29 commented Sep 19, 2019

Thanks @saturnism. This is on our team's radar. Bumping priority to p1.

@tejal29 tejal29 added priority/p1 High impact feature/bug. area/ci-cd labels Sep 19, 2019
@dgageot
Copy link
Contributor

dgageot commented Apr 30, 2020

This is still on the roadmap!

@MarlonGamez
Copy link
Contributor

Hi! It's been a while since we've updated on this. Recently we've been talking about what we want to do with default-repo, as its functionality is currently confusing for a lot of users. I believe we're trying to hammer out those issues before we prioritize this, but we're definitely still looking into this :)

@nkubala nkubala added this to the Backlog [P0/P1] milestone Sep 1, 2020
@briandealwis briandealwis modified the milestones: Backlog [P0/P1], v1.17.0 Oct 28, 2020
@briandealwis briandealwis modified the milestones: v1.17.0, v1.18.0 Nov 25, 2020
@briandealwis briandealwis modified the milestones: v1.18.0, v1.19.0 Jan 25, 2021
@nkubala nkubala modified the milestones: v1.20.0-candidate, Backlog [P0/P1] Feb 9, 2021
@nkubala nkubala removed this from the Backlog [P0/P1] milestone May 11, 2021
@yhrn
Copy link
Contributor

yhrn commented May 13, 2021

Any updates on this? Being able to control this via profiles would be very beneficial for us.

We have multi artifact cases where artifact A needs to go to repo 1 for profile dev/repo 2 for profile prod and artifact B needs to go to repo 3 for profile dev/repo 4 for profile prod. In these cases the command line arg won't work and I can't come up with a reasonably good workaround at all.

@tejal29
Copy link
Member

tejal29 commented May 17, 2021

Currently, we don't have plans to support this in v1, v2 skaffold config.
However, the team is in midst of re-designing v3 skaffold and this is an interesting use case

@tejal29
Copy link
Member

tejal29 commented May 17, 2021

Refer #5857 for v3 config tracking issue

@dhodun
Copy link
Collaborator

dhodun commented May 19, 2021

Interested in this as well. We recently removed the need for namespaces in our app which gave us a lot of flexibility to point skaffold at per-developer and per-PR namespaces. Would be cool to have the same flexibility at the project / cluster / gcr level.

@tejal29
Copy link
Member

tejal29 commented Jul 1, 2021

Thanks @dhodun We will definitely share stuff internally once we have v3 schema ready

@tejal29 tejal29 added this to the v1.38.0 milestone Oct 13, 2021
@tejal29 tejal29 removed this from the v1.38.0 milestone Mar 9, 2022
@tejal29 tejal29 added priority/p2 May take a couple of releases and removed priority/p1 High impact feature/bug. labels Mar 31, 2022
@damlys
Copy link

damlys commented Aug 19, 2022

Totally agree. It would be very useful:

build:
  artifacts:
    - image: myapp
      docker:
        dockerfile: build/myapp/Dockerfile
profiles:
  - name: dev
    deploy:
      defaultRepo: 127.0.0.1:5000             <---
      kubeContext: minikube
      kustomize:
        defaultNamespace: default
        paths:
          - deploy/myapp/overlays/dev

@theodiem
Copy link

Missing the mentioned funcionality and please include at least multi-level-repo also. Allows to:

build:
  artifacts:
    - image: myapp/frontend
      docker:
        dockerfile: build/myapp/Dockerfile.frontend
    - image: myapp/backend
      docker:
        dockerfile: build/myapp/Dockerfile.backend
profiles:
  - name: dev
    deploy:
      multi-level-repo: true                       <---
      defaultRepo: 127.0.0.1:5000             <---

I find very odd that there's global options that you can't configure in a config file and have the globals as an override instead (similar to env vars).

@GeertJohan
Copy link
Contributor

If we can get to a good design / specs I'd be happy to work on an implementation. @tejal29 @briandealwis

Approach 1: Profile only

I suggest to introduce a field profiles[].defaultRepo.

Order of precedence would be:

  • --default-repo flag
  • SKAFFOLD_DEFAULT_REPO env var
  • profile override (the new feature)
  • ~/.skaffold/config

We need to decide on what should happen when two or more profiles set a defaultRepo value. I think the safest thing to do would be to disallow this (exit with an error). The user would then need to split up / redefine profiles so that only one profile ever sets the defaultRepo.

Approach 2: Build setting

Add a new setting build.defaultRepo, which a profile can override with profiles[].build.defaultRepo.

The order of precedence would be roughly the same as approach 1.

@GeertJohan
Copy link
Contributor

Also: should we consider renaming it repo or repository instead of defaultRepo?

@jamesloosli
Copy link

chiming in because I could really use setting multiLevelRepo for all artifacts rather than pasting it everywhere.

@gsquared94
Copy link
Collaborator

In Skaffold v2.2.0, you can now set SKAFFOLD_DEFAULT_REPO=<repository> in a skaffold.env file in the project root. Does this work for your usecase @GeertJohan @jamesloosli ?

@jamesloosli
Copy link

I don't have an issue setting the default repo, I have an issue having to put multiLevelRepo in every artifact declaration everywhere in my monorepo.

@GeertJohan
Copy link
Contributor

@gsquared94 Sorry for the late reply!
I understand correctly that an actual env var SKAFFOLD_DEFAULT_REPO would override the one in the skaffold.env file?
I guess that would work, yes! I'm just wondering why it was chosen to keep this setting as env var though, why not a skaffold.yaml settings with profile overrides, like so many other settings?

@ericzzzzzzz ericzzzzzzz added priority/p1 High impact feature/bug. and removed priority/p2 May take a couple of releases labels Aug 22, 2023
@jjorissen52
Copy link

jjorissen52 commented Sep 13, 2023

We'd love to see the "default repository" feature reimagined to be implemented within profiles.

The thing is, the concept of a global "default repository" for all skaffold projects on one computer never really made sense. That's already acknowledged by 1) detecting docker-desktop and pushing to the correct registry in that case and 2) the ability to set default-repo at for each kube context in your ~/.skaffold/config file. But other developers working on this project on other machines don't have my ~/.skaffold/config file, so I need to carefully document or walk them through how to correctly set the repositories for each project and make sure they know to manually change the kubectx as well (and then hopefully we all remember to change the kubecontext instead of accidentally deploying the dev profile to the staging or prod cluster). Skaffold does a good job of taking complexity out of k8s deployments, but the repository situation requires developers to be much more comfortable with kubectl and related tooling than should really be necessary; simply having a skaffold.yaml as a result of cloning the respository should suffice.

I have many skaffold projects at this point, and none of them share the same repository. And within those projects, I have several profiles which each need to push to different repositories (sometimes targeting different k8s clusters as well), because we have a pattern where we like to have different kustomize overlays for dev/staging/prod which each push to different registries (and/or clusters as the situation demands). This helps us keep each of those environments in different stages of the release cycle, and by having a different registry for each, there can be no confusion about what version of the build is deployed where at any given time.

If you are deploying to Cloud Run (and I assume other targets in the future), you don't even have the option to specify a kubectx, your only option is to invoke skaffold run and set the default repository manually. That looks something like this:

SKAFFOLD_DEFAULT_REPO=really.long-difficult-to.us-central1.io/remember-name-dev skaffold run -p dev
SKAFFOLD_DEFAULT_REPO=really.long-difficult-to.us-central1.io/remember-name-prod skaffold run -p prod

The problem with this is that I (and anyone else I pass this project off on to) needs to remember to set the environment variable or use the --default-repo flag appropriately. How can I enforce that they are choosing the right environment variable so they don't accidentally try to push dev images to the prod registry? Custom tooling, docs, shell scripts, etc, are error prone, time consuming (particularly when I need this to work for a mix of developers using UNIX and Windows!) and still require users to remember to do them.

Even just allowing me to manually specify the artifact as a patch would be a great improvement:

apiVersion: skaffold/v4beta6
kind: Config

build:
  artifacts:
    - image: app
      context: .
      
manifests:
  kustomize:
    paths:
      - .cloudrun/overlays/dev


profiles:
  - name: dev
  - name: staging
    patches:
      - op: replace
        path: /manifests/kustomize/paths/0
        value: .cloudrun/overlays/staging
        # allow me to manually specify the artifact!
      - op: replace
        path: /build/artifacts/0/image
        value: really.long-difficult-to.us-central1.io/remember-name/app

@jrj-d
Copy link

jrj-d commented May 7, 2024

Hi everyone, thanks for the discussion on this topic!
I'm chiming in to say that we would also greatly benefit from being able to specify a default repository per profile.
Right now my team is doing like @jjorissen52 says:

SKAFFOLD_DEFAULT_REPO=really.long-difficult-to.us-central1.io/remember-name-prod skaffold run -p prod

Is there another, perhaps more elegant workaround to this limitation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests