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

Add support for Kubernetes Pull secrets and Pull policies #1617

Merged
merged 2 commits into from
Jan 31, 2019

Conversation

simonferquel
Copy link
Contributor

@simonferquel simonferquel commented Jan 16, 2019

Based on #1615

- What I did

Added support for referencing pull secrets in Compose Files deployed to Kubernetes, and specifying a Pull Policy

- How I did it

Interpret x-pull-secret and x-pull-policy extra fields on ServiceConfig to be mapped to the PullSecret and PullPolicy fields in Compose on Kubernetes v1alpha3 ServiceConfig.

- How to verify it

The PR comes with unit tests covering:

  • correct mapping from x-pull-secret/x-pull-policy to the Compose on Kubernetes Stack representation
  • failure when reading a x-pull-secret/x-pull-policy field when using v1beta1 or v1beta2 endpoints (to avoid updating an existing service and as a side effect remove the pull secret reference)

- Description for the changelog

  • (Experimental) When targetting Kubernetes, add support for x-pull-secret: some-pull-secret in compose-files service configs.
  • (Experimental) When targetting Kubernetes, add support for x-pull-policy: <Never|Always|IfNotPresent> in compose-files service configs.

- A picture of a cute animal (not mandatory but encouraged)
spy cat

@simonferquel
Copy link
Contributor Author

This implements the client side thing of docker/compose-on-kubernetes#27 option 2

@codecov-io
Copy link

codecov-io commented Jan 16, 2019

Codecov Report

Merging #1617 into master will increase coverage by 0.06%.
The diff coverage is 82.69%.

@@            Coverage Diff             @@
##           master    #1617      +/-   ##
==========================================
+ Coverage    56.1%   56.17%   +0.06%     
==========================================
  Files         300      300              
  Lines       20601    20617      +16     
==========================================
+ Hits        11559    11581      +22     
+ Misses       8209     8203       -6     
  Partials      833      833

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking until #1615 get merged, LGTM otherwise.

@simonferquel simonferquel changed the title Add support for Kubernetes Pull secrets Add support for Kubernetes Pull secrets and Pull policies Jan 28, 2019
@simonferquel simonferquel force-pushed the pull-secrets branch 2 times, most recently from 058e8ed to d58defb Compare January 28, 2019 15:54
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
@simonferquel
Copy link
Contributor Author

Just rebased on master. @silvin-lubecki @vdemeester PTAL

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor changes

@simonferquel simonferquel force-pushed the pull-secrets branch 2 times, most recently from 01affb8 to 5b93b7a Compare January 29, 2019 16:00
Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you!

return latest.ServiceConfig{}, err
}
if pullSecret != "" && !capabilities.hasPullSecrets {
return latest.ServiceConfig{}, errors.Errorf("stack API version %s does not support pull secrets (field %q), please use version v1alpha3 or higher", capabilities.apiVersion, PullSecretExtraField)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering; why would I have to manually provide a pull-secret? Would it be possible to automatically resolve credentials for an image and pass them as a pull-secret?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been discussed with @justincormack here: docker/compose-on-kubernetes#27 and the current Swarm seem not to be a very good practice (using user credentials instead of a custom service account)

Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
@simonferquel
Copy link
Contributor Author

@thaJeztah, fields are now unexposed

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra information on the background.

We should indeed work on designing something that can be used both for swarm and k8s. (perhaps allow swarm services to use swarm secrets for pulling?)

Pull policy is also something that needs to be improved for swarm services, so we can work on that as well.

We can change those later, as this PR is using extension fields (so does not modify the compose file spec)

LGTM

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

Successfully merging this pull request may close these issues.

5 participants