Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 39528e4

Browse files
authored
Merge pull request #53 from phillc/merge-for-cli
Merge for-cli branch changes into master
2 parents 3205199 + e5295a7 commit 39528e4

File tree

14 files changed

+53
-68
lines changed

14 files changed

+53
-68
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717

1818
# Logs
1919
*.log
20+

Makefile

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ init:
1414
lint:
1515
terraform fmt -recursive -check -diff .
1616

17-
plan:
17+
plan: check-token
1818
terraform plan
1919

20-
apply:
20+
apply: check-token
2121
terraform apply -auto-approve
2222

23-
destroy:
23+
destroy: check-token
2424
terraform destroy -auto-approve
2525

2626
test: lint init plan apply destroy
27+
28+
check-token:
29+
@if test "$(LINODE_TOKEN)" = "" ; then \
30+
echo "LINODE_TOKEN must be set"; \
31+
exit 1; \
32+
fi

main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ resource "null_resource" "preflight-checks" {
55
}
66

77
provisioner "local-exec" {
8-
command = "${path.module}/scripts/local/preflight.sh"
8+
command = "${path.cwd}/${path.module}/scripts/local/preflight.sh ${var.ccm_image} ${var.csi_image}"
9+
working_dir = "${path.cwd}/${path.module}"
910
}
1011
}
1112

@@ -51,7 +52,7 @@ resource "null_resource" "local_kubectl" {
5152
depends_on = [module.masters]
5253

5354
provisioner "local-exec" {
54-
command = "${path.module}/scripts/local/kubectl-conf.sh ${terraform.workspace} ${module.masters.k8s_master_public_ip} ${module.masters.k8s_master_private_ip} ${var.ssh_public_key}"
55+
command = "${path.cwd}/${path.module}/scripts/local/kubectl-conf.sh ${terraform.workspace} ${module.masters.k8s_master_public_ip} ${module.masters.k8s_master_private_ip} ${var.ssh_public_key}"
5556
on_failure = continue
5657
}
5758
}

modules/instances/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ resource "linode_instance" "instance" {
4646
}
4747

4848
provisioner "file" {
49-
source = "${path.module}/scripts/"
49+
source = "${path.cwd}/${path.module}/scripts/"
5050
destination = "/home/core/init/"
5151

5252
connection {
@@ -61,7 +61,7 @@ resource "linode_instance" "instance" {
6161
"set -e",
6262
"chmod +x /home/core/init/start.sh && sudo /home/core/init/start.sh",
6363
"chmod +x /home/core/init/linode-network.sh && sudo /home/core/init/linode-network.sh ${self.private_ip_address} ${self.label}",
64-
"chmod +x /home/core/init/kubeadm-install.sh && sudo /home/core/init/kubeadm-install.sh ${var.k8s_version} ${var.cni_version} ${var.crictl_version} ${self.label} ${var.use_public ? self.ip_address : self.private_ip_address} ${var.k8s_feature_gates}",
64+
"chmod +x /home/core/init/kubeadm-install.sh && sudo /home/core/init/kubeadm-install.sh \"${var.k8s_version}\" \"${var.cni_version}\" \"${var.crictl_version}\" \"${self.label}\" \"${var.use_public ? self.ip_address : self.private_ip_address}\" \"${var.k8s_feature_gates}\"",
6565
]
6666

6767
connection {

modules/instances/scripts/kubeadm-init.sh

+4-45
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ NODE_PUBLIC_IP="$4"
88
K8S_FEATURE_GATES="$5"
99
POD_NETWORK="10.244.0.0/16"
1010

11-
# Generated with kubeadm config print-default
11+
# Generated with kubeadm config print init-defaults
1212
cat <<EOF > $HOME/kubeadm-config.yml
1313
apiVersion: kubeadm.k8s.io/v1beta1
1414
#bootstrapTokens:
@@ -25,9 +25,7 @@ localAPIEndpoint:
2525
bindPort: 6443
2626
nodeRegistration:
2727
criSocket: /var/run/dockershim.sock
28-
kubeletExtraArgs:
29-
cloud-provider: external
30-
# name: ${NODE_NAME}
28+
name: ${NODE_NAME}
3129
taints:
3230
- effect: NoSchedule
3331
key: node-role.kubernetes.io/master
@@ -39,10 +37,9 @@ apiServer:
3937
cloud-provider: external
4038
feature-gates: ${K8S_FEATURE_GATES}
4139
timeoutForControlPlane: 4m0s
42-
apiVersion: kubeadm.k8s.io/v1beta1
40+
apiVersion: kubeadm.k8s.io/v1beta2
4341
certificatesDir: /etc/kubernetes/pki
44-
clusterName: ${K8S_CLUSTERNAME}
45-
controlPlaneEndpoint: ""
42+
clusterName: kubernetes
4643
controllerManager:
4744
extraArgs:
4845
cloud-provider: external
@@ -60,44 +57,6 @@ networking:
6057
podSubnet: ${POD_NETWORK}
6158
serviceSubnet: 10.96.0.0/12
6259
scheduler: {}
63-
---
64-
apiVersion: kubeproxy.config.k8s.io/v1alpha1
65-
bindAddress: 0.0.0.0
66-
clientConnection:
67-
acceptContentTypes: ""
68-
burst: 10
69-
contentType: application/vnd.kubernetes.protobuf
70-
kubeconfig: /var/lib/kube-proxy/kubeconfig.conf
71-
qps: 5
72-
clusterCIDR: ${POD_NETWORK}
73-
configSyncPeriod: 15m0s
74-
conntrack:
75-
max: null
76-
maxPerCore: 32768
77-
min: 131072
78-
tcpCloseWaitTimeout: 1h0m0s
79-
tcpEstablishedTimeout: 24h0m0s
80-
enableProfiling: false
81-
#healthzBindAddress: 0.0.0.0:10256
82-
hostnameOverride: ""
83-
iptables:
84-
masqueradeAll: false
85-
masqueradeBit: 14
86-
minSyncPeriod: 0s
87-
syncPeriod: 30s
88-
ipvs:
89-
excludeCIDRs: null
90-
minSyncPeriod: 0s
91-
scheduler: ""
92-
syncPeriod: 30s
93-
kind: KubeProxyConfiguration
94-
#metricsBindAddress: 127.0.0.1:10249
95-
mode: ""
96-
nodePortAddresses: null
97-
oomScoreAdj: -999
98-
portRange: ""
99-
resourceContainer: /kube-proxy
100-
udpIdleTimeout: 250ms
10160
EOF
10261

10362
kubeadm init --config $HOME/kubeadm-config.yml

modules/instances/scripts/kubeadm-install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ NODE_IP=$5
99
K8S_FEATURE_GATES="$6"
1010

1111
cat << EOF > /etc/default/kubelet
12-
KUBELET_EXTRA_ARGS="--cloud-provider=external --allow-privileged=true --feature-gates=${K8S_FEATURE_GATES}"
12+
KUBELET_EXTRA_ARGS="--cloud-provider=external --feature-gates=${K8S_FEATURE_GATES}"
1313
EOF
1414

1515
# enable ipvs

modules/instances/scripts/start.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ for mod in ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr nf_conntrack_ipv4; do echo $mod | s
55

66
# Enable the update-engine, but disable the locksmith which it requires
77
sudo systemctl unmask update-engine.service || true
8+
89
sudo systemctl start update-engine.service || true
910
sudo systemctl stop locksmithd.service || true
1011
sudo systemctl mask locksmithd.service || true

modules/masters/main.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resource "null_resource" "masters_provisioner" {
3232
}
3333

3434
provisioner "file" {
35-
source = "${path.module}/manifests/"
35+
source = "${path.cwd}/${path.module}/manifests/"
3636
destination = "/home/core/init/"
3737

3838
connection {
@@ -46,11 +46,11 @@ resource "null_resource" "masters_provisioner" {
4646
# TODO advertise on public adress
4747
inline = [
4848
"set -e",
49-
"chmod +x /home/core/init/kubeadm-init.sh && sudo /home/core/init/kubeadm-init.sh ${var.cluster_name} ${var.k8s_version} ${module.master_instance.public_ip_address} ${module.master_instance.private_ip_address} ${var.k8s_feature_gates}",
49+
"chmod +x /home/core/init/kubeadm-init.sh && sudo /home/core/init/kubeadm-init.sh \"${var.cluster_name}\" \"${var.k8s_version}\" \"${module.master_instance.public_ip_address}\" \"${module.master_instance.private_ip_address}\" \"${var.k8s_feature_gates}\"",
5050
"mkdir -p $HOME/.kube && sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config && sudo chown core $HOME/.kube/config",
5151
"export PATH=$${PATH}:/opt/bin",
5252
"kubectl apply -f /home/core/init/calico.yaml",
53-
"chmod +x /home/core/init/linode-addons.sh && /home/core/init/linode-addons.sh ${var.region} ${var.linode_token}",
53+
"chmod +x /home/core/init/linode-addons.sh && /home/core/init/linode-addons.sh \"${var.region}\" \"${var.linode_token}\"",
5454
"chmod +x /home/core/init/monitoring-install.sh && /home/core/init/monitoring-install.sh",
5555
"chmod +x /home/core/init/update-operator.sh && /home/core/init/update-operator.sh",
5656
"kubectl annotate node $${HOSTNAME} --overwrite container-linux-update.v1.coreos.com/reboot-paused=true",
@@ -66,7 +66,7 @@ resource "null_resource" "masters_provisioner" {
6666
}
6767

6868
data "external" "kubeadm_join" {
69-
program = ["${path.module}/scripts/local/kubeadm-token.sh"]
69+
program = ["${path.cwd}/${path.module}/scripts/local/kubeadm-token.sh"]
7070

7171
query = {
7272
host = module.master_instance.public_ip_address

modules/masters/manifests/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ccm-linode.yaml
2+
csi-linode.yaml

modules/masters/scripts/local/kubeadm-token.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
# Extract "host" argument from the input into HOST shell variable
6-
eval "$(python -c 'import sys, json; print("HOST="+json.load(sys.stdin)["host"])')" 2>/dev/null || true
6+
eval "$(python3 -c 'import sys, json; print("HOST="+json.load(sys.stdin)["host"])')" 2>/dev/null || true
77

88
# TODO: pass the ssh key into this command
99
# Fetch the join command

modules/masters/manifests/ccm-linode.yaml renamed to modules/masters/templates/ccm-linode.yaml.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ spec:
5757
effect: NoSchedule
5858
hostNetwork: true
5959
containers:
60-
- image: linode/linode-cloud-controller-manager:latest
60+
- image: {{ .Values.CCMImage }}
6161
imagePullPolicy: Always
6262
name: ccm-linode
6363
args:

modules/masters/manifests/csi-linode.yaml renamed to modules/masters/templates/csi-linode.yaml.template

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ spec:
341341
- name: socket-dir
342342
mountPath: /var/lib/csi/sockets/pluginproxy/
343343
- name: linode-csi-plugin
344-
image: linode/linode-blockstorage-csi-driver:v0.1.0
344+
image: {{ .Values.CSIImage }}
345345
args :
346346
- "--endpoint=$(CSI_ENDPOINT)"
347347
- "--token=$(LINODE_TOKEN)"
@@ -417,7 +417,7 @@ spec:
417417
- name: registration-dir
418418
mountPath: /registration/
419419
- name: csi-linode-plugin
420-
image: linode/linode-blockstorage-csi-driver:v0.1.0
420+
image: {{ .Values.CSIImage }}
421421
args :
422422
- "--endpoint=$(CSI_ENDPOINT)"
423423
- "--token=$(LINODE_TOKEN)"

scripts/local/preflight.sh

+9
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ function assertInstalled() {
1111
}
1212

1313
assertInstalled ssh scp sed kubectl python
14+
15+
CCM_IMAGE=$1
16+
CSI_IMAGE=$2
17+
18+
# substitute Docker images in manifests
19+
20+
sed -e "s|{{ \.Values\.CCMImage }}|${CCM_IMAGE}|g" modules/masters/templates/ccm-linode.yaml.template > modules/masters/manifests/ccm-linode.yaml
21+
sed -e "s|{{ \.Values\.CSIImage }}|${CSI_IMAGE}|g" modules/masters/templates/csi-linode.yaml.template > modules/masters/manifests/csi-linode.yaml
22+

variables.tf

+13-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ variable "crictl_version" {
1414
}
1515

1616
variable "k8s_feature_gates" {
17-
default = "CSINodeInfo=true,CSIDriverRegistry=true,BlockVolume=true,CSIBlockVolume=true"
17+
default = ""
1818
description = "Feature gates to enable in the Kubelet and API server"
1919
}
2020

@@ -53,12 +53,6 @@ variable "linode_token" {
5353
description = "Linode API v4 Personal Access Token"
5454
}
5555

56-
variable "ssh_private_key" {
57-
type = string
58-
default = "~/.ssh/id_rsa"
59-
description = "The path to your private key"
60-
}
61-
6256
variable "ssh_public_key" {
6357
type = string
6458
default = "~/.ssh/id_rsa.pub"
@@ -70,3 +64,15 @@ variable "update_agent_reboot_paused" {
7064
default = "true"
7165
description = "Pause the container-linux update-agent operator from triggering reboots. Defaults to 'true' (Paused) to prevent the control-plane from rebooting in the first few minutes of the cluster's life-cycle."
7266
}
67+
68+
variable "ccm_image" {
69+
type = string
70+
default = "linode/linode-cloud-controller-manager:latest"
71+
description = "The docker repo/image:tag to use for the CCM"
72+
}
73+
74+
variable "csi_image" {
75+
type = string
76+
default = "linode/linode-blockstorage-csi-driver:latest"
77+
description = "The docker repo/image:tag to use for the CSI"
78+
}

0 commit comments

Comments
 (0)