Skip to content

Expose pod tempting on acme http issuer#1749

Merged
jetstack-bot merged 7 commits intocert-manager:masterfrom
JoshVanL:pod-templating
Jun 11, 2019
Merged

Expose pod tempting on acme http issuer#1749
jetstack-bot merged 7 commits intocert-manager:masterfrom
JoshVanL:pod-templating

Conversation

@JoshVanL
Copy link
Copy Markdown
Contributor

@JoshVanL JoshVanL commented Jun 5, 2019

Signed-off-by: JoshVanL vleeuwenjoshua@gmail.com

What this PR does / why we need it:
Exposes a core.PodTemplate resource for the ACME HTTP issuer config.
This enables one to change values around the solver pod, i.e. labels and annotations.
It uses the current cert-manager values as a default and "merges" custom values ontop.

fixes #1097

Special notes for your reviewer:

Expose pod template for the ACME issuer solver pod

/assign

@jetstack-bot jetstack-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 5, 2019
@jetstack-bot jetstack-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Jun 5, 2019
@jetstack-bot jetstack-bot requested a review from munnerz June 5, 2019 14:27
@jetstack-bot jetstack-bot added area/acme Indicates a PR directly modifies the ACME Issuer code area/acme/http01 Indicates a PR modifies ACME HTTP01 provider code area/api Indicates a PR directly modifies the 'pkg/apis' directory kind/documentation Categorizes issue or PR as related to documentation. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 5, 2019
JoshVanL added 3 commits June 7, 2019 10:41
validation

Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
Copy link
Copy Markdown
Member

@munnerz munnerz left a comment

Choose a reason for hiding this comment

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

Looks good. I've added a few comments, notably I'm starting to think we should be more and more careful with the fields we do allow users to set.

This could be used as a privilege escalation point if we are not careful, as lower-privileged users are able to configure cert-manager to create resources that they otherwise may not be able to create.

I'm beginning to think we may be best off creating our own PodTemplateSpec like structure that for the time being only contains ObjectMeta, and then setting the "fields allowed to be overridden" to be a whitelist instead of a blacklist (i.e. we only allow labels & annotations initially). This would at least prevent any new fields that we aren't currently aware of being utilised by an attacker/evil user 😄

// Optional template to configure the solver pods. Not all pod template
// options are valid (e.g. name).
// +optional
PodTemplate corev1.PodTemplateSpec `json:"podTemplate,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be a field under ingress, as it is specifically a configuration option that the Ingress based HTTP01 solver uses (which is coincidentally the only HTTP01 solver type we support).

We should also make this a *corev1.PodTemplateSpec, as a user may omit this field altogether, and we can then identify 'not set' values.

namespace: default
labels:
environment: production
foo: bar
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(based on previous experience in these docs) - we should include the full YAML structure here else it confuses users. If there are extra verbose parts that aren't relevant when doing so, you can replace the irrelevant fields with ... so long as you keep the indentation correct

foo: bar

Unless changed, the pod's metadata will remain the default for each unedited
field when a podTemplate is specified.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

will remain the default for each unedited field when a podTemplate is specified. can you reword this? I'm a bit lost as to what you're trying to convey. Maybe: If not specified, a default set of metadata will be applied to the generated solver pod.?

namespace: default
labels:
environment: production
foo: bar
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It also looks like you are missing the metadata field here. Perhaps this is why you were having issues in your tests? I'd expect it to look something like:

           podTemplate:
             metadata:
               namespace: default
               labels:
                 environment: production
                 foo: bar

Ingress *ACMEChallengeSolverHTTP01Ingress `json:"ingress"`

// Optional template to configure the solver pods. Not all pod template
// options are valid (e.g. name).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you expand this comment out some more?

Optional pod template used to configure the ACME challenge solver pods used for HTTP01 challenges.
Setting this option could lead to unintended side-effects, however it may be necessary when running
in certain network restricted environments (e.g. Istio).
Only `metadata` fields can be set here. All other fields will be ignored.
The `metadata.name` and `metadata.namespace` fields cannot be overridden.

el = append(el, field.Invalid(fldPath.Child("podTemplate"), sol.PodTemplate.GenerateName, "generateName cannot be set for solver pod template"))
}

if sol.PodTemplate.Spec.String() != new(corev1.PodSpec).String() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😬 this seems awkward. Can we instead compare if sol.PodTemplate.Spec != corev1.PodSpec{}? I think that'll work as expected, because if both are not set then they will both have empty values set for all of their fields.

// Override defaults if they have changed in the pod template.
if ch.Spec.Solver != nil {
pod = s.mergePodObjectMetaWithPodTemplate(pod,
ch.Spec.Solver.HTTP01.PodTemplate.DeepCopy())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Deep copy shouldn't be needed here as we don't actually modify podTempl in the mergePodObjectMetaWithPodTemplate method

@JoshVanL
Copy link
Copy Markdown
Contributor Author

JoshVanL commented Jun 7, 2019

Thanks for the comments @munnerz, really useful. Will get to making changes now

JoshVanL added 2 commits June 9, 2019 18:37
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
@JoshVanL JoshVanL changed the title WIP: expose pod tempting on acme http issuer Expose pod tempting on acme http issuer Jun 10, 2019
@jetstack-bot jetstack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 10, 2019
@JoshVanL
Copy link
Copy Markdown
Contributor Author

/unassign
/assign @munnerz

@jetstack-bot jetstack-bot assigned munnerz and unassigned JoshVanL Jun 10, 2019
Copy link
Copy Markdown
Member

@munnerz munnerz left a comment

Choose a reason for hiding this comment

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

Just a few final comments.. all looks good to me 😄

Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
@JoshVanL
Copy link
Copy Markdown
Contributor Author

Thanks @munnerz, back to you :)

@munnerz
Copy link
Copy Markdown
Member

munnerz commented Jun 11, 2019

/lgtm
/approve

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 11, 2019
@jetstack-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoshVanL, munnerz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/acme/http01 Indicates a PR modifies ACME HTTP01 provider code area/acme Indicates a PR directly modifies the ACME Issuer code area/api Indicates a PR directly modifies the 'pkg/apis' directory dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/documentation Categorizes issue or PR as related to documentation. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allowing specifying ACME solver pod template

3 participants