-
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
Changes from 28 commits
f990efe
6095ae6
6c347ec
a02fc4f
258f115
ba7cc8a
482ae82
2545f2c
285cf1c
51cb468
550bd4a
0d78af3
272f5dc
12ad764
95c562f
448ccb0
91877da
01bdac2
d569560
d637020
9bd672f
031d4c8
0aca48b
ec64eb7
de0051b
6c8130f
6a502ff
89eef35
f0faa06
f73674a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,10 @@ services: | |
container_name: simulator-server | ||
environment: | ||
- PORT=1212 | ||
- KUBE_SCHEDULER_SIMULATOR_ETCD_URL=http://simulator-etcd:2379 | ||
- CORS_ALLOWED_ORIGIN_LIST=http://${SIMULATOR_EXTERNAL_IP:-localhost}:3000 | ||
sanposhiho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- KUBE_API_HOST=0.0.0.0 | ||
- KUBE_API_PORT=3131 | ||
- KUBE_SCHEDULER_SIMULATOR_ETCD_URL=http://simulator-cluster:2379 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need an alias for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sounds simple and clear for me to define as ETCD_URL There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have to worry about the env. The configuration thru env is deprecated and we'll remove them eventually. So, the current way of configuring is basically thru scheduler config file, which has EtcdURL instead of this messy long title. |
||
- KUBE_APISERVER_URL=http://simulator-cluster:3131 | ||
ports: | ||
- "1212:1212" | ||
- "3131:3131" | ||
restart: always | ||
tty: true | ||
networks: | ||
|
@@ -27,17 +24,19 @@ services: | |
ports: | ||
- "3000:3000" | ||
tty: true | ||
simulator-etcd: | ||
image: quay.io/coreos/etcd:v3.4.26 | ||
container_name: simulator-etcd | ||
simulator-cluster: | ||
image: registry.k8s.io/kwok/cluster:v0.5.0-k8s.v1.29.0 | ||
container_name: simulator-cluster | ||
restart: always | ||
ports: | ||
- "3131:3131" | ||
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 | ||
- ./kwok.yaml:/root/.kwok/kwok.yaml | ||
sanposhiho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
networks: | ||
- simulator-internal-network | ||
volumes: | ||
simulator-etcd-data: | ||
networks: | ||
simulator-internal-network: | ||
driver: bridge | ||
volumes: | ||
simulator-etcd-data: |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,12 @@ | ||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
etcdPort: 2379 | ||||
etcdPrefix: /kube-scheduler-simulator | ||||
disableKubeScheduler: true | ||||
componentsPatches: | ||||
- name: kube-apiserver | ||||
extraArgs: | ||||
- key: cors-allowed-origins | ||||
value: ^*$ | ||||
sanposhiho marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,10 @@ func NewConfig() (*Config, error) { | |
return nil, xerrors.Errorf("get frontend URL: %w", err) | ||
} | ||
|
||
apiurl := getKubeAPIServerURL() | ||
apiurl, err := getKubeAPIServerURL() | ||
if err != nil { | ||
return nil, xerrors.Errorf("get kube API server URL: %w", err) | ||
} | ||
|
||
externalimportenabled := getExternalImportEnabled() | ||
externalKubeClientCfg := &rest.Config{} | ||
|
@@ -136,23 +139,15 @@ func getPort() (int, error) { | |
} | ||
|
||
// getKubeAPIServerURL gets KubeAPIServerURL from environment variable first, if empty from the config file. | ||
func getKubeAPIServerURL() string { | ||
p := os.Getenv("KUBE_API_PORT") | ||
if p == "" { | ||
p = strconv.Itoa(configYaml.KubeAPIPort) | ||
if p == "" { | ||
p = "3131" | ||
} | ||
} | ||
|
||
h := os.Getenv("KUBE_API_HOST") | ||
if h == "" { | ||
h = configYaml.KubeAPIHost | ||
if h == "" { | ||
h = "127.0.0.1" | ||
Comment on lines
-140
to
-152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, we no longer need to keep these configurations actually. But, we cannot immediately remove them because it'd be a breaking change. For now, please add a note on the document of config that they're old configuration and will be removed very soon. |
||
func getKubeAPIServerURL() (string, error) { | ||
url := os.Getenv("KUBE_APISERVER_URL") | ||
if url == "" { | ||
url = configYaml.KubeAPIServerURL | ||
if url == "" { | ||
return "", xerrors.Errorf("get KUBE_APISERVER_URL from config: %w", ErrEmptyConfig) | ||
} | ||
} | ||
return h + ":" + p | ||
return url, nil | ||
} | ||
|
||
// getExternalSchedulerEnabled gets ExternalSchedulerEnabled from environment variable first, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
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.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.