-
Notifications
You must be signed in to change notification settings - Fork 143
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
migrate the internal kube-apiserver to kwok #333
Conversation
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Hi @sivchari. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
docker-compose-local.yml
Outdated
simulator-etcd: | ||
image: quay.io/coreos/etcd:v3.4.26 | ||
container_name: simulator-etcd | ||
restart: always | ||
volumes: | ||
- simulator-etcd-data:/var/lib/etcd | ||
command: etcd --advertise-client-urls http://simulator-etcd:2379 --data-dir /var/lib/etcd --listen-client-urls http://0.0.0.0:2379 --initial-cluster-state new --initial-cluster-token tkn | ||
networks: | ||
- simulator-internal-network | ||
volumes: | ||
simulator-etcd-data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to create clusters use image, so that the simulator doesn't need to be concerned with the creation and deletion of clusters at all, and only needs to be externally supplied with etcd ports.
simulator-cluster:
image: registry.k8s.io/kwok/cluster:v0.5.0-k8s.v1.29.0
container_name: simulator-cluster
restart: always
ports:
- "8080:8080"
environment:
- KWOK_KUBE_APISERVER_PORT=8080
volumes:
- simulator-etcd-data:/var/lib/etcd
- ./kwokctl.yaml:/root/.kwok/kwok.yaml
# kwokctl.yaml
kind: KwokctlConfiguration
apiVersion: config.kwok.x-k8s.io/v1alpha1
options:
etcdPort: 2379
etcdPrefix: /kube-scheduler-simulator
disableKubeScheduler: true
componentsPatches:
- name: kube-apiserver
extraArgs:
- key: cors-allowed-origins
value: ^*$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the clutter. Although I tried to fix these codes, it couldn't catch the watchResources response. it's suspended and I don't have no idea why it's caused. Do you have some idea ?
/ok-to-test |
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
@sanposhiho @wzshiming |
/cc @sanposhiho |
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
@sanposhiho @wzshiming |
@@ -5,12 +5,15 @@ This page describes how the simulator works. | |||
### 0. starts the simulator. | |||
|
|||
The simulator server works with the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simulator server works with the following: | |
The simulator server contains the following components: |
simulator/docs/how-it-works.md
Outdated
- [kube-apiserver](kube-apiserver.md) | ||
- etcd | ||
- scheduler | ||
- controllers for core resources | ||
- [HTTP server](api.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [kube-apiserver](kube-apiserver.md) | |
- etcd | |
- scheduler | |
- controllers for core resources | |
- [HTTP server](api.md) | |
- scheduler | |
- [HTTP server](api.md) |
simulator/docs/kube-apiserver.md
Outdated
@@ -1,5 +1,11 @@ | |||
## Kube-apiserver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just remove this page
simulator/docs/how-it-works.md
Outdated
In advance, the simulator needs to launch etcd, controllers and kube-apiserver outside. | ||
[KWOK](/~https://github.com/kubernetes-sigs/kwok) can launch these components all at once, thus we recommend using it. | ||
When the simulator server starts, it will start scheduler and HTTP server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In advance, the simulator needs to launch etcd, controllers and kube-apiserver outside. | |
[KWOK](/~https://github.com/kubernetes-sigs/kwok) can launch these components all at once, thus we recommend using it. | |
When the simulator server starts, it will start scheduler and HTTP server. | |
In advance, the simulator needs to launch etcd, controller-manager and kube-apiserver outside. | |
We recommend using [KWOK](/~https://github.com/kubernetes-sigs/kwok), see [docker-compose.yml](../../docker-compose.yml) to know how we wire things up. |
When the simulator server starts, it will start these components with server. | ||
In advance, the simulator needs to launch etcd, controllers and kube-apiserver outside. | ||
[KWOK](/~https://github.com/kubernetes-sigs/kwok) can launch these components all at once, thus we recommend using it. | ||
When the simulator server starts, it will start scheduler and HTTP server. | ||
|
||
### 1. users request creating resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kwok should support most of resources and we no longer need to list supported resources. We can simplify this section like:
### 1. users request creating resource.
Users can create resources below by communicating with kube-apiserver of Kwok via any clients
(e.g., kubectl, kwokctl, k8s client library or [Web UI](../../web))
### 2. the scheduler schedules a new pod
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, Please modify README too.
simulator/simulator.go
Outdated
time.Sleep(1 * time.Second) | ||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) | ||
defer cancel() | ||
wait.UntilWithContext(ctx, func(ctx context.Context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misled in a previous comment.
We should use PollUntilContextTimeout rather, otherwise wait.UntilWithContext
wouldn't panic or error out if reaching timeout seemingly.
https://pkg.go.dev/k8s.io/apimachinery/pkg/util/wait#PollUntilContextTimeout
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
@@ -41,12 +41,12 @@ We have several components: | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update Getting started
section like this otherwise people cannot run up the simulator correctly until a new release is cut.
## Getting started
git clone git@github.com:kubernetes-sigs/kube-scheduler-simulator.git
cd kube-scheduler-simulator
# switch to the version you want to use.
git switch simulator/v0.1.1
# pull images from the registry and run up all components
make docker_up
# All things up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'd revise it.
README.md
Outdated
You can create any resources by communication with kube-apiserver outside via any clients (e.g. kubectl, k8s client library, or web UI described next). | ||
And when you create Pods, | ||
Pods will be scheduled by the [debuggable scheduler](./simulator/docs/debuggable-scheduler.md), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
You can create any resources by communication with kube-apiserver outside via any clients (e.g. kubectl, k8s client library, or web UI described next). | |
And when you create Pods, | |
Pods will be scheduled by the [debuggable scheduler](./simulator/docs/debuggable-scheduler.md), | |
Simulator runs with a fake cluster powered by [KWOK](/~https://github.com/kubernetes-sigs/kwok) | |
You can create any resources in KWOK cluster via any clients (e.g. kubectl, k8s client library, or web UI described next). | |
And when you create Pods, | |
Pods will be scheduled by the [debuggable scheduler](./simulator/docs/debuggable-scheduler.md), |
simulator/simulator.go
Outdated
_, err := client.CoreV1().Namespaces().Get(context.Background(), "kube-system", metav1.GetOptions{}) | ||
if err != nil { | ||
klog.Infof("waiting for kube-system namespace to be ready: %v", err) | ||
return false, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if we here return err, it'd immediately fail without retry. Let's just return nill as we log error in L65.
return false, err | |
return false, nil |
simulator/config/config.go
Outdated
url := os.Getenv("KUBE_APISERVER_URL") | ||
if url == "" && configYaml.KubeAPIServerURL != "" { | ||
return configYaml.KubeAPIServerURL | ||
} | ||
p := os.Getenv("KUBE_API_PORT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove L145-160, but without removing KubeAPIPort and KubeAPIHost from simulator/config/v1alpha1/types.go
. We can just ignore deprecated envs (as I said before, removing them would be a breaking change that we should avoid though
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
I've updated PR, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the image startup script is hardcoded, the only way to set this is through the environment variable.
and the next release (kubernetes-sigs/kwok#999) will support kubeApiserverInsecurePort
to instead of this
kwok.yaml
Outdated
kind: KwokctlConfiguration | ||
apiVersion: config.kwok.x-k8s.io/v1alpha1 | ||
options: | ||
kubeApiserverPort: 3131 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kubeApiserverPort: 3131 |
Signed-off-by: sivchari <shibuuuu5@gmail.com>
@wzshiming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two doc changes, otherwise LGTM
@@ -28,15 +33,20 @@ origin for `CORS_ALLOWED_ORIGIN_LIST`. | |||
resources". This variable is used to find Kubeconfig required to | |||
access your cluster for importing resources to scheduler simulator. | |||
|
|||
`KUBE_APISEVER_URL`: This is the URL of kube-apiserver which the | |||
simulator uses. This variable is used to connect to external kube-apiserver. | |||
|
|||
`KUBE_API_HOST`: This is the host of kube-apiserver which the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, on second thought, I don't think we need to keep the mention of KUBE_API_HOST and KUBE_API_PORT.
Can we just remove L8-L12 and L36-L45?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We forget about the doc in:
/~https://github.com/kubernetes-sigs/kube-scheduler-simulator/blob/f0faa06ec7773723073ad04c4bb3383dbbd8d3ff/simulator/docs/simulator-server-config.md
Can you
- remove the mention to kubeApiHost and kubeApiPort
- mention kubeApiServerUrl
over there?
Signed-off-by: sivchari <shibuuuu5@gmail.com>
@sanposhiho |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
@sivchari This is epic, thanks for your all effort!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sanposhiho, sivchari 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 |
Also thanks @wzshiming for your all support! It'd be hard to achieve if you weren't here. |
What type of PR is this?
/area simulator
/kind feature
/kind cleanup
What this PR does / why we need it:
Before this PR, we should manage not only kube-scheduler, but also kube-apiserver and etcd.
We wanna focus on kube-scheduler and reduce the time when we maintain various components.
Therefore, this aims to integrate kwok into simulator that simulates Nodes and Clusters..
If this PR is merged, all we have to do only maintain scheduler-simulator.
Which issue(s) this PR fixes:
Fixes #251
Special notes for your reviewer:
/label tide/merge-method-squash