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

Adding a metadata proxy addon #45565

Merged
merged 1 commit into from
Jun 3, 2017
Merged

Conversation

Q-Lee
Copy link
Contributor

@Q-Lee Q-Lee commented May 9, 2017

What this PR does / why we need it: adds a metadata server proxy daemonset to hide kubelet secrets.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): this partially addresses #8867

Special notes for your reviewer:

Release note: the gce metadata server can be hidden behind a proxy, hiding the kubelet's token.

The gce metadata server can be hidden behind a proxy, hiding the kubelet's token.

@Q-Lee Q-Lee requested review from cjcullen and piosz May 9, 2017 22:44
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 9, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels May 9, 2017
@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 9, 2017

You can find the proxy image here: kubernetes-retired/contrib#2576

@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 10, 2017

@k8s-bot kops aws e2e test this

# Note that this does not guarantee admission on the nodes (#40573).
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
Copy link
Contributor

Choose a reason for hiding this comment

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

Resource requests are missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@@ -1423,6 +1423,9 @@ function start-kube-addons {
if [[ "${ENABLE_DEFAULT_STORAGE_CLASS:-}" == "true" ]]; then
setup-addon-manifests "addons" "storage-class/gce"
fi
if [[ "${ENABLE_METADATA_PROXY:-}" == "simple" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Why only in GCI? You should add it at least to debian, as some of our tests run on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I've tried adding it to configure-vm.sh and the salt files.

@piosz piosz self-assigned this May 11, 2017
- name: config-volume
mountPath: /etc/nginx/
nodeSelector:
beta.kubernetes.io/metadata-proxy-ready: "true"
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this label? Similar label was introduced for fluentd because historically it ran as a manifest pod and we wanted to avoid situation where we will end up with 2 instances of fluentd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The label is so we'll only run it on node pools where the daemonset is enabled.

Copy link
Member

Choose a reason for hiding this comment

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

Do you have any use where you want to have it enabled for some nodes and disabled for others within the same cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing and migration of existing clusters.

Copy link
Member

Choose a reason for hiding this comment

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

Do you need to run metadata proxy addon on nodes in version 1.x+ and do not run it on nodes in version <1.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is also the case.

@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 16, 2017

@k8s-bot unit test this

@@ -0,0 +1,4 @@
approvers:
- q-lee
Copy link
Contributor

Choose a reason for hiding this comment

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

it'd be better to have at least one other name here to avoid the bus problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added mike/cj.

==============

This metadata proxy returns a 403 for kubelet's secrets, but otherwise allows
pods through to the metadata server.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/through/access/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

# Metadata proxy
==============

This metadata proxy returns a 403 for kubelet's secrets, but otherwise allows
Copy link
Member

Choose a reason for hiding this comment

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

"secrets" is probably misleading here. Maybe say that it returns a 403 for the configuration data stored in kube-env.

NODE_LABELS="${KUBE_NODE_LABELS:-beta.kubernetes.io/fluentd-ds-ready=true}"
NODE_LABELS="${KUBE_NODE_LABELS:-beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/metadata-proxy-ready=true}"

# Turn the simple metadata proxy on by default.
Copy link
Member

Choose a reason for hiding this comment

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

Is defaulting this on safe? Seems like this could break workloads that happen to be depending on something they shouldn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dependencies on kube-env cannot be supported. If we're required to support unknown dependencies there, then we're unable to make just about any internal change whatsoever.

@roberthbailey roberthbailey removed their assignment May 19, 2017
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 20, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 23, 2017
@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 23, 2017

@k8s-bot pull-kubernetes-unit test this
@k8s-bot pull-kubernetes-federation-e2e-gce test this

@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 23, 2017

@k8s-bot pull-kubernetes-e2e-kops-aws test this

@cjcullen
Copy link
Member

Squash commits, and then this ells gee to me.

@@ -0,0 +1,60 @@
kind: ConfigMap
Copy link
Member

Choose a reason for hiding this comment

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

Is there an integration or e2e test that tests this configuration? i.e. the allow/deny rules are correct and work as intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The happy cases should be well tested by feature tests (e.g., logging and monitoring tests should fail in the absence of a metadata server). I intend to push a negative case test after this goes in.

labels:
addonmanager.kubernetes.io/mode: EnsureExists
data:
nginx.conf: |-
Copy link
Member

Choose a reason for hiding this comment

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

We should think about minimizing the work the proxy is doing here to keep it simple. I took a quick tour through options here:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html

proxy_cache: do we care? Maybe this should be off, might reduce any hard-to-debug cache weirdness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah, so it is. This LGTM.

@jbeda
Copy link
Contributor

jbeda commented May 26, 2017

Hate to swoop in here but this thing should be named gce-metadata-proxy as it is very GCE specific.

@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 27, 2017

@jbeda How gce specific is it really? Is the aws metadata server laid out much differently (that's not a rhetorical question)? Are there no secrets on the aws metadata server we would want to block using a different nginx config? Could someone want to run kube2iam using this mechanism?

I did consider the directory structure metadata-proxy/gce. Perhaps that's better? It defers a lot of thinking.

@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 31, 2017

@jbeda - does "metadata-proxy/gce" sound like a reasonable solution?
@gmarek - any chance of an lgtm?

@gmarek
Copy link
Contributor

gmarek commented May 31, 2017

IIRC @piosz were reviewing this

@Q-Lee
Copy link
Contributor Author

Q-Lee commented May 31, 2017

Fair enough, pinging @piosz

@Q-Lee
Copy link
Contributor Author

Q-Lee commented Jun 1, 2017

@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this
@k8s-bot pull-kubernetes-unit test this

@piosz
Copy link
Member

piosz commented Jun 1, 2017

/lgtm
for configuration part

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2017
@k8s-github-robot k8s-github-robot added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Jun 1, 2017
@Q-Lee Q-Lee added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. labels Jun 1, 2017
@Q-Lee
Copy link
Contributor Author

Q-Lee commented Jun 1, 2017

/assign @mikedanese

Can this get approval?

@mikedanese
Copy link
Member

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Q-Lee, mikedanese, piosz

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 1, 2017
@Q-Lee Q-Lee added this to the v1.7 milestone Jun 2, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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.