Skip to content

Commit 46dab60

Browse files
authored
refine config.yaml file (#8)
* chore(*): refine config.yaml file and remove nginx push server * chore(*): fix ntp server address typo
1 parent 7702ffd commit 46dab60

File tree

9 files changed

+222
-298
lines changed

9 files changed

+222
-298
lines changed

compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ services:
88
restart: always
99
volumes:
1010
- ./resources/nginx:/usr/share/nginx
11-
- ./config/compose/auth.htpasswd:/etc/nginx/conf.d/auth.htpasswd
1211
- ./config/compose/certs/domain.crt:/etc/nginx/conf.d/domain.crt
1312
- ./config/compose/certs/domain.key:/etc/nginx/conf.d/domain.key
1413
- ./config/compose/nginx.conf:/etc/nginx/conf.d/default.conf
1514
ports:
1615
- 443:443
17-
- 5000:5000
1816
- 8080:8080
1917

2018
registry:
@@ -23,3 +21,5 @@ services:
2321
restart: always
2422
volumes:
2523
- ./resources/registry:/var/lib/registry
24+
ports:
25+
- 127.0.0.1:5000:5000

config.yaml

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
compose:
2+
# Compose bootstrap node ip, default is local internal ip
3+
internal_ip: 172.20.0.25
24
# Nginx http server bind port for download files and packages
35
nginx_http_port: 8080
4-
# For container runtime pull image, use 443 as default
5-
registry_https_port: 443
6-
# For user push image to this registry, use 5000 as default
7-
registry_push_port: 5000
8-
# Registry host ip for add to /etc/hosts by domain
9-
registry_ip: 172.20.0.25
10-
# Registry domain for CRI runtime download image
6+
# Registry domain for CRI runtime download images
117
registry_domain: kube.registry.local
12-
# Auto generate self-signed certificate for registry domain
13-
generate_crt: true
14-
# User and password for push image to registry
15-
registry_auth_user: "Username"
16-
registry_auth_password: "Password"
17-
# Registry image repo, default library
18-
image_repo: library
198

209
kubespray:
2110
# Kubernetes version by default, only support v1.20.6
@@ -24,20 +13,15 @@ kubespray:
2413
external_apiserver_access_ip: 127.0.0.1
2514
# Set network plugin to calico with vxlan mode by default
2615
kube_network_plugin: calico
27-
# Set true to download and cache container
28-
download_container: false
29-
# Use nginx and registry provide all offline resources
30-
offline_resources_enabled: true
3116
#Container runtime, only support containerd if offline deploy
3217
container_manager: containerd
3318
# Now only support host if use containerd as CRI runtime
3419
etcd_deployment_type: host
3520
# Settings for etcd event server
3621
etcd_events_cluster_setup: true
3722
etcd_events_cluster_enabled: true
38-
# Kubespray container image for deploy user cluster
39-
kubespray_image: ""
4023

24+
# Cluster nodes inventory info
4125
inventory:
4226
all:
4327
vars:
@@ -79,3 +63,29 @@ inventory:
7963
hosts: {}
8064
calico_rr:
8165
hosts: {}
66+
67+
### Default parameters ###
68+
## This filed not need config, will auto update,
69+
## if no special requirement, do not modify these parameters.
70+
default:
71+
# NTP server ip address or domain, default is internal_ip
72+
ntp_server:
73+
- internal_ip
74+
# Registry ip address, default is internal_ip
75+
registry_ip: internal_ip
76+
# Offline resource url for download files, default is internal_ip:nginx_http_port
77+
offline_resources_url: internal_ip:nginx_http_port
78+
# Use nginx and registry provide all offline resources
79+
offline_resources_enabled: true
80+
# Image repo in registry
81+
image_repository: library
82+
# Kubespray container image for deploy user cluster or scale
83+
kubespray_image: "kubespray"
84+
# Auto generate self-signed certificate for registry domain
85+
generate_domain_crt: true
86+
# For nodes pull image, use 443 as default
87+
registry_https_port: 443
88+
# For push image to this registry, use 5000 as default, and only bind at 127.0.0.1
89+
registry_push_port: 5000
90+
# Set false to disable download all container images on all nodes
91+
download_container: false

config/compose/nginx.conf

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -75,49 +75,3 @@ server {
7575
proxy_read_timeout 900;
7676
}
7777
}
78-
79-
# This server listen at 5000 for push image by auth_basic auth
80-
server {
81-
listen 5000 ssl;
82-
listen [::]:5000;
83-
server_name kube.registry.local;
84-
85-
# SSL
86-
ssl_certificate /etc/nginx/conf.d/domain.crt;
87-
ssl_certificate_key /etc/nginx/conf.d/domain.key;
88-
89-
# Recommendations from https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
90-
ssl_protocols TLSv1.1 TLSv1.2;
91-
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
92-
ssl_prefer_server_ciphers on;
93-
ssl_session_cache shared:SSL:10m;
94-
95-
# disable any limits to avoid HTTP 413 for large image uploads
96-
client_max_body_size 0;
97-
98-
# required to avoid HTTP 411: see Issue #1486 (https://github.com/moby/moby/issues/1486)
99-
chunked_transfer_encoding on;
100-
101-
location /v2/ {
102-
# Do not allow connections from docker 1.5 and earlier
103-
# docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents
104-
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
105-
return 404;
106-
}
107-
108-
# To add basic authentication to v2 use auth_basic setting.
109-
auth_basic "Registry realm";
110-
auth_basic_user_file /etc/nginx/conf.d/auth.htpasswd;
111-
112-
## If $docker_distribution_api_version is empty, the header is not added.
113-
## See the map directive above where this variable is defined.
114-
add_header 'Docker-Distribution-Api-Version' $docker_distribution_api_version always;
115-
116-
proxy_pass http://docker-registry;
117-
proxy_set_header Host $http_host; # required for docker client's sake
118-
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
119-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
120-
proxy_set_header X-Forwarded-Proto $scheme;
121-
proxy_read_timeout 900;
122-
}
123-
}

install.sh

Lines changed: 43 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
INSTALL_TYPE=$1
33
: ${INSTALL_TYPE:=all}
44

5-
# Common utilities, variables and checks for all build scripts.
5+
# Common utilities, variables and checks for all scripts.
66
set -o errexit
77
set -o nounset
88
set -o pipefail
@@ -12,7 +12,7 @@ USR_BIN_PATH=/usr/local/bin
1212
export PATH="${PATH}:${USR_BIN_PATH}"
1313
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
1414

15-
# Define glob vars
15+
# Define glob variables
1616
KUBE_ROOT="$(cd "$(dirname "$0")" && pwd)"
1717
CERTS_DIR="${KUBE_ROOT}/config/certs"
1818
CONFIG_FILE="${KUBE_ROOT}/config.yaml"
@@ -25,10 +25,10 @@ RESOURCES_NGINX_DIR="${KUBE_ROOT}/resources/nginx"
2525
KUBESPRAY_CONFIG_DIR="${KUBE_ROOT}/config/kubespray"
2626
INSTALL_STEPS_FILE="${KUBESPRAY_CONFIG_DIR}/.install_steps"
2727

28-
# Import all functions from scripts/*.sh
29-
for file in ${KUBE_ROOT}/scripts/*.sh; do source ${file}; done
28+
# Include all functions from library/*.sh
29+
for file in ${KUBE_ROOT}/library/*.sh; do source ${file}; done
3030

31-
# Get os release info
31+
# Gather os-release variables
3232
if ! source /etc/os-release; then
3333
errorlog "Every system that we officially support has /etc/os-release"
3434
exit 1
@@ -39,63 +39,49 @@ if [ ! -f ${CONFIG_FILE} ]; then
3939
exit 1
4040
fi
4141

42-
usage(){
43-
cat <<EOF
44-
Usage: install.sh [TYPE] [NODE_NAME]
45-
The script is used for install kubernetes cluster
46-
47-
Parameter:
48-
[TYPE]\t this param is used to determine what to do with the kubernetes cluster.
49-
Available type as follow:
50-
all deploy compose addon and kubernetes cluster
51-
compose deploy nginx and registry server
52-
deploy-cluster install kubernetes cluster
53-
remove-cluster remove kubernetes cluster
54-
add-node add worker node to kubernetes cluster
55-
remove-node remove worker node to kubernetes cluster
56-
debug run debug mode for install or troubleshooting
57-
58-
[NODE_NAME] this param to choose node for kubespray to exceute.
59-
Note: when [TYPE] is specified [add-node] or [remove-node] this parameter must be set
60-
multiple nodes are separated by commas, example: node01,node02,node03
61-
62-
EOF
63-
exit 0
64-
}
65-
66-
deploy_cluster(){
42+
deploy_compose(){
43+
case ${ID} in
44+
Debian|debian)
45+
system::debian::config_repo
46+
;;
47+
CentOS|centos)
48+
system::centos::disable_selinux
49+
system::centos::config_repo
50+
;;
51+
Ubuntu|ubuntu)
52+
system::ubuntu::config_repo
53+
;;
54+
*)
55+
errorlog "Not support system: ${ID}"
56+
exit 1
57+
;;
58+
esac
59+
system::disable_firewalld
60+
system::install_pkgs
61+
common::install_tools
6762
common::rudder_config
68-
common::push_kubespray_image
69-
common::run_kubespray "bash /kubespray/run.sh deploy-cluster"
70-
}
71-
72-
add_nodes(){
73-
common::run_kubespray "bash /kubespray/run.sh add-node $2"
74-
}
75-
76-
remove_nodes(){
77-
common::run_kubespray "bash /kubespray/run.sh remove-node $2"
78-
}
79-
80-
kubespray_debug(){
81-
common::run_kubespray "bash"
82-
}
83-
84-
install_all(){
85-
bootstrap
86-
deploy_cluster
63+
common::update_hosts
64+
common::generate_domain_certs
65+
common::load_images
66+
common::compose_up
67+
common::health_check
68+
system::install_chrony
8769
}
8870

8971
main(){
9072
case ${INSTALL_TYPE} in
9173
all)
92-
install_all
74+
deploy_compose
75+
common::push_kubespray_image
76+
common::run_kubespray "bash /kubespray/run.sh deploy-cluster"
9377
;;
9478
compose)
95-
bootstrap
79+
deploy_compose
9680
;;
9781
cluster)
98-
deploy_cluster
82+
common::rudder_config
83+
common::push_kubespray_image
84+
common::run_kubespray "bash /kubespray/run.sh deploy-cluster"
9985
;;
10086
remove)
10187
common::rudder_config
@@ -111,21 +97,23 @@ main(){
11197
remove::remove_compose
11298
;;
11399
add-nodes)
100+
common::run_kubespray "bash /kubespray/run.sh add-node $2"
114101
;;
115102
remove-node)
103+
common::run_kubespray "bash /kubespray/run.sh remove-node $2"
116104
;;
117105
health-check)
118106
common::health_check
119107
;;
120108
debug)
121-
kubespray_debug
109+
common::run_kubespray "bash"
122110
;;
123111
-h|--help|help)
124-
usage
112+
common::usage
125113
;;
126114
*)
127115
echowarn "unknow [TYPE] parameter: ${INSTALL_TYPE}"
128-
usage
116+
common::usage
129117
;;
130118
esac
131119
}

0 commit comments

Comments
 (0)