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

Auto-pause handle internal kubernetes requests #10823

Merged
merged 10 commits into from
Mar 29, 2021

Conversation

azhao155
Copy link
Contributor

@azhao155 azhao155 commented Mar 15, 2021

Start minikube with auto-pause

zyanshu@zyanshukvm:~/minikube$  ./out/minikube  start --addons=auto-pause
😄  minikube v1.18.1 on Debian rodete (kvm/amd64)
✨  Automatically selected the docker driver. Other choices: kvm2, ssh
👍  Starting control plane node minikube in cluster minikube
🔥  Creating docker container (CPUs=2, Memory=26100MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
    ▪ Using image gcr.io/haproxy:2.3.5
    ▪ Using image docker.io/azhao155/auto-pause-hook:1.5
    ▪ auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.
    ▪ https://github.com/kubernetes/minikube/labels/co%2Fauto-pause
🌟  Enabled addons: storage-provisioner, default-storageclass, auto-pause
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

env-inject will be created under auto-pause namespace

zyanshu@zyanshukvm:~/minikube$ kubectl get pods -A
NAMESPACE     NAME                               READY   STATUS             RESTARTS   AGE
auto-pause    auto-pause-proxy-dc6979c79-4x9mh   1/1     Running            0          39s
auto-pause    env-inject-547b5d649d-gjnqg        1/1     Running            0          39s
kube-system   coredns-74ff55c5b-dv48v            0/1     CrashLoopBackOff   1          39s
kube-system   etcd-minikube                      0/1     Running            0          53s
kube-system   kube-apiserver-minikube            1/1     Running            0          53s
kube-system   kube-controller-manager-minikube   0/1     Running            0          53s
kube-system   kube-proxy-b9x8r                   1/1     Running            0          39s
kube-system   kube-scheduler-minikube            0/1     Running            0          53s
kube-system   storage-provisioner                1/1     Running            0          52s

Deploy etcd-operator

zyanshu@zyanshukvm:~/etcd-operator$ kubectl apply -f example/deployment.yaml
deployment.apps/etcd-operator created

etcd-operator is running now

zyanshu@zyanshukvm:~/minikube$ kubectl get pods -A
NAMESPACE     NAME                               READY   STATUS             RESTARTS   AGE
auto-pause    auto-pause-proxy-dc6979c79-hxx9b   1/1     Running            0          3m38s
auto-pause    env-inject-547b5d649d-hpz98        1/1     Running            0          3m38s
default       etcd-operator-7f8df45d-fwgvh       1/1     Running            0          63s
kube-system   coredns-74ff55c5b-wpk94            0/1     CrashLoopBackOff   6          3m38s
kube-system   etcd-minikube                      1/1     Running            0          3m53s
kube-system   kube-apiserver-minikube            1/1     Running            0          3m53s
kube-system   kube-controller-manager-minikube   1/1     Running            0          3m53s
kube-system   kube-proxy-ssvrv                   1/1     Running            0          3m38s
kube-system   kube-scheduler-minikube            1/1     Running            0          3m53s
kube-system   storage-provisioner                1/1     Running            1          3m52s

Check env of etcd-operator

zyanshu@zyanshukvm:~/minikube$ kubectl exec etcd-operator-7f8df45d-fwgvh -- env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=etcd-operator-7f8df45d-fwgvh
KUBERNETES_SERVICE_HOST=192.168.49.2
KUBERNETES_SERVICE_PORT=32443
MY_POD_NAMESPACE=default
MY_POD_NAME=etcd-operator-7f8df45d-fwgvh
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT=tcp://10.96.0.1:443
KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1
HOME=/home/etcd-operator

It's already pointing to reverse proxy.
Deploy etcd-cluster

zyanshu@zyanshukvm:~/etcd-operator$ kubectl create -f ./example/example-etcd-cluster.yaml
etcdcluster.etcd.database.coreos.com/example-etcd-cluster created

etcd-cluster is deployed

zyanshu@zyanshukvm:~/minikube$ kubectl get pods
 
NAME                              READY     STATUS    RESTARTS   AGE
etcd-operator-7f8df45d-fwgvh      1/1       Running   0          9m
example-etcd-cluster-9bxfh657qq   1/1       Running   0          23s
example-etcd-cluster-ntzp4hrw79   1/1       Running   0          8m
example-etcd-cluster-xwlpqrzj2q   1/1       Running   0          9m

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 15, 2021
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 15, 2021
Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

since we are creating an image for the webhook, what do u think about moving the auto-pause server into the same image ?

and then run the Auto-Pause server as a Docker or Crictl Container inside minikube VM (or container)

@azhao155 azhao155 changed the title WIP add webhook to inject env to redirect in cluster kubectl request to haproxy. Add auto-pause webhook to inject env into pods for redirecting in-cluster kubectl request to reverse proxy of api server. Mar 17, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 17, 2021
@azhao155
Copy link
Contributor Author

since we are creating an image for the webhook, what do u think about moving the auto-pause server into the same image ?

and then run the Auto-Pause server as a Docker or Crictl Container inside minikube VM (or container)

To do that, we need to create the image contains docker and run container in privileged mode. I could try that once this pr is done.

pkg/minikube/assets/addons.go Outdated Show resolved Hide resolved
cmd/auto-pause/auto-pause-hook/config.go Outdated Show resolved Hide resolved
cmd/auto-pause/auto-pause-hook/main.go Outdated Show resolved Hide resolved
cmd/auto-pause/auto-pause-hook/main.go Outdated Show resolved Hide resolved
deploy/addons/auto-pause/Dockerfile Show resolved Hide resolved
pkg/minikube/assets/addons.go Outdated Show resolved Hide resolved
cmd/auto-pause/auto-pause-hook/main.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
cmd/auto-pause/auto-pause-hook/config.go Show resolved Hide resolved
@medyagh
Copy link
Member

medyagh commented Mar 27, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Mar 27, 2021
@minikube-pr-bot
Copy link

kvm2 Driver
error collecting results for kvm2 driver: timing run 0 with minikube: timing cmd: [/home/performance-monitor/minikube/out/minikube start --driver=kvm2]: waiting for minikube: exit status 69
docker Driver
error collecting results for docker driver: timing run 0 with Minikube (PR 10823): timing cmd: [/home/performance-monitor/.minikube/minikube-binaries/10823/minikube start --driver=docker]: starting cmd: fork/exec /home/performance-monitor/.minikube/minikube-binaries/10823/minikube: exec format error

@@ -99,6 +99,9 @@ SHA512SUM=$(shell command -v sha512sum || echo "shasum -a 512")
# to update minikubes default, update deploy/addons/gvisor
GVISOR_TAG ?= latest

# auto-pause-hook tag to push changes to
AUTOPAUSE_HOOK_TAG ?= 1.13
Copy link
Member

Choose a reason for hiding this comment

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

lets not use the Dot notation here, it should be a simple One letter version,
like V1

@medyagh medyagh merged commit 660cc42 into kubernetes:master Mar 29, 2021
@medyagh medyagh changed the title Add auto-pause webhook to inject env into pods for redirecting in-cluster kubectl request to reverse proxy of api server. Auto-pause handle internal kubernetes requests Mar 29, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: azhao155, medyagh

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 29, 2021
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants