Skip to content

Commit 85c2d1d

Browse files
authored
Merge pull request #359 from AkihiroSuda/dev
Consistently remove "U7S_" prefix from all the variables
2 parents 251bb6a + 21331b3 commit 85c2d1d

5 files changed

Lines changed: 51 additions & 63 deletions

File tree

Dockerfile.d/u7s-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eux -o pipefail
33

44
# Append "KUBELET_EXTRA_ARGS=..." in /etc/default/kubelet
5-
sed -e "s!\(^KUBELET_EXTRA_ARGS=.*\)!\\1 --cloud-provider=external --node-labels=usernetes/host-ip=${U7S_HOST_IP}!" </etc/default/kubelet | sponge /etc/default/kubelet
5+
sed -e "s!\(^KUBELET_EXTRA_ARGS=.*\)!\\1 --cloud-provider=external --node-labels=usernetes/host-ip=${HOST_IP}!" </etc/default/kubelet | sponge /etc/default/kubelet
66

77
# Import control plane hosts from previous boot
88
[ -e /etc/hosts.u7s ] && cat /etc/hosts.u7s >>/etc/hosts

Makefile

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,48 @@
11
# Run `make help` to show usage
22
.DEFAULT_GOAL := help
33

4-
HOSTNAME ?= $(shell hostname)
5-
# HOSTNAME is the name of the physical host
6-
export HOSTNAME := $(HOSTNAME)
7-
84
# Change ports for different kubernetes services
9-
PORT_ETCD ?= 2379
10-
PORT_KUBELET ?= 10250
11-
PORT_FLANNEL ?= 8472
12-
PORT_KUBE_APISERVER ?= 6443
13-
14-
export U7S_PORT_ETCD := $(PORT_ETCD)
15-
export U7S_PORT_KUBELET := $(PORT_KUBELET)
16-
export U7S_PORT_FLANNEL := $(PORT_FLANNEL)
17-
export U7S_PORT_KUBE_APISERVER := $(PORT_KUBE_APISERVER)
18-
19-
HOST_IP ?= $(shell ip --json route get 1 | jq -r .[0].prefsrc)
20-
NODE_NAME ?= u7s-$(HOSTNAME)
21-
NODE_SUBNET ?= $(shell $(CURDIR)/Makefile.d/node-subnet.sh)
22-
# U7S_HOST_IP is the IP address of the physical host. Accessible from other hosts.
23-
export U7S_HOST_IP := $(HOST_IP)
24-
# U7S_NODE_NAME is the host name of the Kubernetes node running in Rootless Docker.
5+
export PORT_ETCD ?= 2379
6+
export PORT_KUBELET ?= 10250
7+
export PORT_FLANNEL ?= 8472
8+
export PORT_KUBE_APISERVER ?= 6443
9+
10+
# HOSTNAME is the name of the physical host
11+
export HOSTNAME ?= $(shell hostname)
12+
# HOST_IP is the IP address of the physical host. Accessible from other hosts.
13+
export HOST_IP ?= $(shell ip --json route get 1 | jq -r .[0].prefsrc)
14+
# NODE_NAME is the host name of the Kubernetes node running in Rootless Docker.
2515
# Not accessible from other hosts.
26-
export U7S_NODE_NAME:= $(NODE_NAME)
27-
# U7S_NODE_NAME is the subnet of the Kubernetes node running in Rootless Docker.
16+
export NODE_NAME ?= u7s-$(HOSTNAME)
17+
# NODE_SUBNET is the subnet of the Kubernetes node running in Rootless Docker.
2818
# Not accessible from other hosts.
29-
export U7S_NODE_SUBNET := $(NODE_SUBNET)
30-
# U7S_NODE_IP is the IP address of the Kubernetes node running in Rootless Docker.
19+
export NODE_SUBNET ?= $(shell $(CURDIR)/Makefile.d/node-subnet.sh)
20+
# NODE_IP is the IP address of the Kubernetes node running in Rootless Docker.
3121
# Not accessible from other hosts.
32-
export U7S_NODE_IP := $(subst .0/24,.100,$(U7S_NODE_SUBNET))
22+
export NODE_IP := $(subst .0/24,.100,$(NODE_SUBNET))
3323

34-
CONTAINER_ENGINE ?= $(shell $(CURDIR)/Makefile.d/detect-container-engine.sh CONTAINER_ENGINE)
35-
export CONTAINER_ENGINE := $(CONTAINER_ENGINE)
24+
export CONTAINER_ENGINE ?= $(shell $(CURDIR)/Makefile.d/detect-container-engine.sh CONTAINER_ENGINE)
3625

37-
CONTAINER_ENGINE_TYPE ?= $(shell $(CURDIR)/Makefile.d/detect-container-engine.sh CONTAINER_ENGINE_TYPE)
38-
export CONTAINER_ENGINE_TYPE := $(CONTAINER_ENGINE_TYPE)
26+
export CONTAINER_ENGINE_TYPE ?= $(shell $(CURDIR)/Makefile.d/detect-container-engine.sh CONTAINER_ENGINE_TYPE)
3927

4028
COMPOSE ?= $(shell $(CURDIR)/Makefile.d/detect-container-engine.sh COMPOSE)
4129

4230
NODE_SERVICE_NAME := node
4331
NODE_SHELL := $(COMPOSE) exec \
44-
-e U7S_HOST_IP=$(U7S_HOST_IP) \
45-
-e U7S_NODE_NAME=$(U7S_NODE_NAME) \
46-
-e U7S_NODE_SUBNET=$(U7S_NODE_SUBNET) \
47-
-e U7S_NODE_IP=$(U7S_NODE_IP) \
48-
-e U7S_PORT_KUBE_APISERVER=$(U7S_PORT_KUBE_APISERVER) \
49-
-e U7S_PORT_FLANNEL=$(U7S_PORT_FLANNEL) \
50-
-e U7S_PORT_KUBELET=$(U7S_PORT_KUBELET) \
51-
-e U7S_PORT_ETCD=$(U7S_PORT_ETCD) \
32+
-e HOST_IP=$(HOST_IP) \
33+
-e NODE_NAME=$(NODE_NAME) \
34+
-e NODE_SUBNET=$(NODE_SUBNET) \
35+
-e NODE_IP=$(NODE_IP) \
36+
-e PORT_KUBE_APISERVER=$(PORT_KUBE_APISERVER) \
37+
-e PORT_FLANNEL=$(PORT_FLANNEL) \
38+
-e PORT_KUBELET=$(PORT_KUBELET) \
39+
-e PORT_ETCD=$(PORT_ETCD) \
5240
$(NODE_SERVICE_NAME)
5341

5442
ifeq ($(CONTAINER_ENGINE),nerdctl)
5543
ifneq (,$(wildcard $(XDG_RUNTIME_DIR)/bypass4netnsd.sock))
56-
export U7S_B4NN := true
57-
export U7S_B4NN_IGNORE_SUBNETS := ["10.96.0.0/16", "10.244.0.0/16", "$(U7S_NODE_SUBNET)"]
44+
export BYPASS4NETNS := true
45+
export BYPASS4NETNS_IGNORE_SUBNETS := ["10.96.0.0/16", "10.244.0.0/16", "$(NODE_SUBNET)"]
5846
endif
5947
endif
6048

Makefile.d/install-flannel.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ set -eu -o pipefail
33

44
# See chart values, 0 indicates default for platform
55
# https://github.com/flannel-io/flannel/blob/v0.26.1/chart/kube-flannel/values.yaml
6-
: "${U7S_PORT_FLANNEL:='0'}"
6+
: "${PORT_FLANNEL:='0'}"
77

88
if ! helm -n kube-flannel list -q | grep flannel; then
99
kubectl create namespace kube-flannel
1010
kubectl label --overwrite namespace kube-flannel pod-security.kubernetes.io/enforce=privileged
11-
helm install flannel --namespace kube-flannel --set-json flannel.backendPort=${U7S_PORT_FLANNEL} /flannel
11+
helm install flannel --namespace kube-flannel --set-json flannel.backendPort=${PORT_FLANNEL} /flannel
1212
fi

docker-compose.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Use `make up`, not `docker compose up`,
2-
# as this YAML requires ${U7S_...} variables to be set.
2+
# as this YAML requires ${...} variables to be set.
33
---
44
services:
55
node:
66
build: .
7-
hostname: ${U7S_NODE_NAME}
7+
hostname: ${NODE_NAME}
88
privileged: true
99
restart: always
1010
networks:
1111
default:
12-
ipv4_address: ${U7S_NODE_IP}
12+
ipv4_address: ${NODE_IP}
1313
ports:
1414
# <host>:<container>
1515
# etcd (default: 2379)
16-
- ${U7S_PORT_ETCD}:${U7S_PORT_ETCD}
16+
- ${PORT_ETCD}:${PORT_ETCD}
1717
# kube-apiserver (default: 6443)
18-
- ${U7S_PORT_KUBE_APISERVER}:${U7S_PORT_KUBE_APISERVER}
18+
- ${PORT_KUBE_APISERVER}:${PORT_KUBE_APISERVER}
1919
# kubelet (default: 10250)
20-
- ${U7S_PORT_KUBELET}:${U7S_PORT_KUBELET}
20+
- ${PORT_KUBELET}:${PORT_KUBELET}
2121
# flannel (default: 8472)
22-
- ${U7S_PORT_FLANNEL}:${U7S_PORT_FLANNEL}/udp
22+
- ${PORT_FLANNEL}:${PORT_FLANNEL}/udp
2323
volumes:
2424
- .:/usernetes:ro
2525
- /boot:/boot:ro
@@ -34,24 +34,24 @@ services:
3434
working_dir: /usernetes
3535
environment:
3636
KUBECONFIG: /etc/kubernetes/admin.conf
37-
U7S_HOST_IP: ${U7S_HOST_IP}
37+
HOST_IP: ${HOST_IP}
3838
sysctls:
3939
- net.ipv4.ip_forward=1
4040
# In addition, `net.ipv4.conf.default.rp_filter`
4141
# has to be set to 0 (disabled) or 2 (loose)
4242
# in the daemon's network namespace.
4343
annotations:
4444
# Accelerate network for nerdctl >= 2.0.0-beta.4 with bypass4netns >= 0.4.1
45-
"nerdctl/bypass4netns": "${U7S_B4NN:-false}"
45+
"nerdctl/bypass4netns": "${BYPASS4NETNS:-false}"
4646
"nerdctl/bypass4netns-ignore-bind": "true"
47-
"nerdctl/bypass4netns-ignore-subnets": "${U7S_B4NN_IGNORE_SUBNETS:-}"
47+
"nerdctl/bypass4netns-ignore-subnets": "${BYPASS4NETNS_IGNORE_SUBNETS:-}"
4848
networks:
4949
default:
5050
ipam:
5151
config:
5252
# Each of the nodes has to have a different IP.
5353
# The node IP here is not accessible from other nodes.
54-
- subnet: ${U7S_NODE_SUBNET}
54+
- subnet: ${NODE_SUBNET}
5555
volumes:
5656
node-var: {}
5757
node-opt: {}

kubeadm-config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
apiVersion: kubeadm.k8s.io/v1beta4
22
kind: InitConfiguration
33
localAPIEndpoint:
4-
bindPort: ${U7S_PORT_KUBE_APISERVER}
4+
bindPort: ${PORT_KUBE_APISERVER}
55
---
66
apiVersion: kubeadm.k8s.io/v1beta4
77
kind: ClusterConfiguration
8-
controlPlaneEndpoint: "${U7S_NODE_NAME}:${U7S_PORT_KUBE_APISERVER}"
8+
controlPlaneEndpoint: "${NODE_NAME}:${PORT_KUBE_APISERVER}"
99
apiServer:
1010
certSANs:
1111
- localhost
1212
- 127.0.0.1
13-
- "${U7S_NODE_NAME}"
14-
- "${U7S_HOST_IP}"
13+
- "${NODE_NAME}"
14+
- "${HOST_IP}"
1515
extraArgs:
1616
- name: etcd-servers
17-
value: https://127.0.0.1:${U7S_PORT_ETCD}
17+
value: https://127.0.0.1:${PORT_ETCD}
1818
- name: advertise-address
19-
value: ${U7S_HOST_IP}
19+
value: ${HOST_IP}
2020
- name: secure-port
21-
value: "${U7S_PORT_KUBE_APISERVER}"
21+
value: "${PORT_KUBE_APISERVER}"
2222
- name: cloud-provider
2323
value: external
2424
# Default: "Hostname,InternalDNS,InternalIP,ExternalDNS,ExternalIP"
@@ -35,14 +35,14 @@ etcd:
3535
local:
3636
extraArgs:
3737
- name: listen-client-urls
38-
value: "https://127.0.0.1:${U7S_PORT_ETCD},https://${U7S_NODE_IP}:${U7S_PORT_ETCD}"
38+
value: "https://127.0.0.1:${PORT_ETCD},https://${NODE_IP}:${PORT_ETCD}"
3939
- name: advertise-client-urls
40-
value: https://${U7S_NODE_IP}:${U7S_PORT_ETCD}
40+
value: https://${NODE_IP}:${PORT_ETCD}
4141
---
4242
kind: KubeletConfiguration
4343
apiVersion: kubelet.config.k8s.io/v1beta1
4444
failSwapOn: false
45-
port: ${U7S_PORT_KUBELET}
45+
port: ${PORT_KUBELET}
4646
featureGates:
4747
KubeletInUserNamespace: true
4848
---

0 commit comments

Comments
 (0)