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

Admission Controller Fix #5248

Merged

Conversation

gambol99
Copy link
Contributor

@gambol99 gambol99 commented Jun 2, 2018

A previous PR #5221 introduced the --enable-admission-plugins for >= 1.10.0 as recommended, it does however cause an issue if you already have AdmissionControl specified in the Spec as both flags get rendered and they are mutually exclusive, causing the kube-apiserver not to start

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 2, 2018
@gambol99
Copy link
Contributor Author

gambol99 commented Jun 2, 2018

I'm guessing the e2e tests didn't pick this up because they aren't specifying any AdmissionControl. Without this the kube-apiserver throws the below and refuses to start.

I0602 18:35:54.052373       1 server.go:135] Version: v1.10.3
I0602 18:35:54.052787       1 server.go:724] external host was not specified, using 10.250.31.254
admission-control and enable-admission-plugins/disable-admission-plugins flags are mutually exclusive

@gambol99 gambol99 force-pushed the fix_admissions_controllers branch from 4a674ca to 93e7fed Compare June 2, 2018 18:44
A previous PR kubernetes#5221 introduced the --enable-admission-plugins for >= 1.10.0 as recommended, it does however cause an issue if you already have AdmissionControl is specified in the Spec as both flags get rendered
@gambol99 gambol99 force-pushed the fix_admissions_controllers branch from 93e7fed to b62d6df Compare June 2, 2018 18:47
@gambol99
Copy link
Contributor Author

gambol99 commented Jun 2, 2018

Just double checked by building out a cluster

core@ip-10-250-31-61 /etc/kubernetes/manifests $ cat kube-apiserver.manifest
...
  containers:
  - command:
    - /bin/sh
    - -c
    - mkfifo /tmp/pipe; (tee -a /var/log/kube-apiserver.log < /tmp/pipe & ) ; exec
      /usr/local/bin/kube-apiserver --allow-privileged=true --anonymous-auth=false
      --apiserver-count=3 --audit-log-maxage=3 --audit-log-path=/var/lib/docker/kubernetes/logs/apiserver-audit.log
      --audit-policy-file=/srv/kubernetes/audit-policy.yaml --authentication-token-webhook-cache-ttl=3m0s
      --authentication-token-webhook-config-file=/srv/kubernetes/token-webhook.yaml
      --authorization-mode=RBAC --basic-auth-file=/srv/kubernetes/basic_auth.csv --bind-address=0.0.0.0
      --client-ca-file=/srv/kubernetes/ca.crt --cloud-provider=aws --enable-admission-plugins=Initializers,MutatingAdmissionWebhook,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,PodSecurityPolicy,ResourceQuota,DefaultTolerationSeconds,ValidatingAdmissionWebhook
      --etcd-cafile=/srv/kubernetes/ca.crt --etcd-certfile=/srv/kubernetes/etcd-client.pem
      --etcd-keyfile=/srv/kubernetes/etcd-client-key.pem --etcd-servers-overrides=/events#https://127.0.0.1:4002
      --etcd-servers=https://127.0.0.1:4001 --experimental-encryption-provider-config=/srv/kubernetes/encryptionconfig.yaml
      --feature-gates=ExpandPersistentVolumes=true --insecure-bind-address=127.0.0.1
      --insecure-port=8080 --kubelet-client-certificate=/srv/kubernetes/kubelet-api.pem
      --kubelet-client-key=/srv/kubernetes/kubelet-api-key.pem --kubelet-preferred-address-types=InternalIP,Hostname,ExternalIP
      --proxy-client-cert-file=/srv/kubernetes/apiserver-aggregator.cert --proxy-client-key-file=/srv/kubernetes/apiserver-aggregator.key
      --requestheader-allowed-names=aggregator --requestheader-client-ca-file=/srv/kubernetes/apiserver-aggregator-ca.cert
      --requestheader-extra-headers-prefix=X-Remote-Extra- --requestheader-group-headers=X-Remote-Group
      --requestheader-username-headers=X-Remote-User --runtime-config=admissionregistration.k8s.io/v1beta1=true
      --secure-port=443 --service-cluster-ip-range=10.10.0.0/19 --storage-backend=etcd3
      --tls-cert-file=/srv/kubernetes/server.cert --tls-private-key-file=/srv/kubernetes/server.key
      --token-auth-file=/srv/kubernetes/known_tokens.csv --v=1 > /tmp/pipe 2>&1
    image: k8s.gcr.io/kube-apiserver:v1.10.3

@gambol99
Copy link
Contributor Author

gambol99 commented Jun 2, 2018

/assign @justinsb

@justinsb
Copy link
Member

justinsb commented Jun 2, 2018

Thanks for the fix.

/approve
/lgtm

We should also validate that users haven't set both (we should make that an error, because we aren't going to honor both).

I think it would also make more sense to do this in pkg/model/components/apiserver.go - we can also raise an error if users have set both, which we can't do in nodeup (though this would be a failsafe test; we should primarily do this in validation).

Ideally we would also log a warning if users are setting AdmissionControl with k8s >= 1.10 as they should be moving to EnableAdmissionControl.

I will try to tackle these if I have time (unless you beat me to it), but this is a good and important fix - thank you!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 2, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gambol99, justinsb

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot merged commit 6a0d885 into kubernetes:master Jun 2, 2018
@gambol99 gambol99 deleted the fix_admissions_controllers branch June 2, 2018 20:12
gambol99 added a commit to gambol99/kops that referenced this pull request Jun 2, 2018
Since v1.10.0 the --admission-control is being deprecated in favour or --enable-admission-plugin, we should enforce the behaviour in the validation code

I did a fix for this a [moment ago](kubernetes#5248), but yes, enforcement is a better option than trying to support both
gambol99 added a commit to gambol99/kops that referenced this pull request Jun 4, 2018
Since v1.10.0 the --admission-control is being deprecated in favour or --enable-admission-plugin, we should enforce the behaviour in the validation code

I did a fix for this a [moment ago](kubernetes#5248), but yes, enforcement is a better option than trying to support both
gambol99 added a commit to gambol99/kops that referenced this pull request Jun 4, 2018
Since v1.10.0 the --admission-control is being deprecated in favour or --enable-admission-plugin, we should enforce the behaviour in the validation code

I did a fix for this a [moment ago](kubernetes#5248), but yes, enforcement is a better option than trying to support both
gambol99 added a commit to gambol99/kops that referenced this pull request Jun 5, 2018
Since v1.10.0 the --admission-control is being deprecated in favour or --enable-admission-plugin, we should enforce the behaviour in the validation code

I did a fix for this a [moment ago](kubernetes#5248), but yes, enforcement is a better option than trying to support both
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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants