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

Commit

Permalink
chore: bump kind and k8s version
Browse files Browse the repository at this point in the history
- bump kind client to v0.8.1
- bump k8s version to v1.18.2
- add netcat to dapper builder

BREAKING CHANGE: bump kind version to v0.8.1
  • Loading branch information
Frank Mai authored and guangbochen committed Jun 5, 2020
1 parent c896d4f commit ddeae42
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13.9-buster
RUN apt-get update && \
apt-get install -y xz-utils unzip
apt-get install -y xz-utils unzip netcat

# -- for make rules
## install docker
Expand Down
2 changes: 1 addition & 1 deletion adaptors/ble/Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13.9-buster
RUN apt-get update && \
apt-get install -y xz-utils unzip
apt-get install -y xz-utils unzip netcat

# -- for make rules
## install docker
Expand Down
2 changes: 1 addition & 1 deletion adaptors/dummy/Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13.9-buster
RUN apt-get update && \
apt-get install -y xz-utils unzip
apt-get install -y xz-utils unzip netcat

# -- for make rules
## install docker
Expand Down
2 changes: 1 addition & 1 deletion adaptors/modbus/Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13.9-buster
RUN apt-get update && \
apt-get install -y xz-utils unzip
apt-get install -y xz-utils unzip netcat

# -- for make rules
## install docker
Expand Down
2 changes: 1 addition & 1 deletion adaptors/mqtt/Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13.9-buster
RUN apt-get update && \
apt-get install -y xz-utils unzip
apt-get install -y xz-utils unzip netcat

# -- for make rules
## install docker
Expand Down
2 changes: 1 addition & 1 deletion adaptors/opcua/Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13.9-buster
RUN apt-get update && \
apt-get install -y xz-utils unzip
apt-get install -y xz-utils unzip netcat

# -- for make rules
## install docker
Expand Down
50 changes: 39 additions & 11 deletions hack/lib/cluster-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# Kind cluster variables helpers. These functions need the
# following variables:
#
# KIND_VERSION - The Kind version for running, default is v0.7.0.
# K8S_VERSION - The Kubernetes version for the cluster, default is v1.17.2.
# KIND_VERSION - The Kind version for running, default is v0.8.1.
# K8S_VERSION - The Kubernetes version for the cluster, default is v1.18.2.
# CLUSTER_NAME - The name for the cluster, default is edge.
# CONTROL_PLANES - The number of the control-plane, default is 1.
# WORKERS - The number of the workers, default is 3.

K8S_VERSION=${K8S_VERSION:-"v1.17.2"}
K8S_VERSION=${K8S_VERSION:-"v1.18.2"}
CLUSTER_NAME=${CLUSTER_NAME:-"edge"}

function octopus::cluster_kind::install() {
local version=${KIND_VERSION:-"v0.7.0"}
local version=${KIND_VERSION:-"v0.8.1"}
curl -fL "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-$(octopus::util::get_os)-$(octopus::util::get_arch)" -o /tmp/kind
chmod +x /tmp/kind && mv /tmp/kind /usr/local/bin/kind
}
Expand All @@ -38,6 +38,8 @@ function octopus::cluster_kind:setup_configuration() {
cat >"${config}" <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
apiServerAddress: "0.0.0.0"
nodes:
EOF

Expand All @@ -46,10 +48,39 @@ EOF
control_planes=1
fi
for ((i = 0; i < control_planes; i++)); do
# shellcheck disable=SC2086
cat >>${config} <<EOF
if [[ ${i} -eq 0 ]]; then
local random_port_start
random_port_start=$(octopus::util::get_random_port_start 2)
local ingress_http_port=$((random_port_start + 0))
octopus::log::info "INGRESS_HTTP_PORT is ${ingress_http_port}"
export INGRESS_HTTP_PORT=${ingress_http_port}
local ingress_https_port=$((random_port_start + 1))
octopus::log::info "INGRESS_HTTPS_PORT is ${ingress_https_port}"
export INGRESS_HTTPS_PORT=${ingress_https_port}

# shellcheck disable=SC2086
cat >>${config} <<EOF
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: ${ingress_http_port}
protocol: TCP
- containerPort: 443
hostPort: ${ingress_https_port}
protocol: TCP
EOF
else
# shellcheck disable=SC2086
cat >>${config} <<EOF
- role: control-plane
EOF
fi
done

local workers=${WORKERS:-3}
Expand All @@ -61,8 +92,6 @@ EOF
- role: worker
EOF
done

echo -n "${config}"
}

function octopus::cluster_kind::startup() {
Expand All @@ -78,10 +107,9 @@ function octopus::cluster_kind::startup() {

octopus::log::info "creating ${CLUSTER_NAME} cluster with ${K8S_VERSION}"
# setup cluster
local config
config=$(octopus::cluster_kind:setup_configuration)
octopus::cluster_kind:setup_configuration
local kind_image="kindest/node:${K8S_VERSION}"
kind create cluster --name "${CLUSTER_NAME}" --config "${config}" --image "${kind_image}" --wait 5m
kind create cluster --name "${CLUSTER_NAME}" --config "/tmp/kind-${CLUSTER_NAME}-cluster-config.yaml" --image "${kind_image}" --wait 5m

octopus::log::info "${CLUSTER_NAME} cluster's kubeconfig has wrote in the ~/.kube/config"
}
Expand Down
22 changes: 22 additions & 0 deletions hack/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,25 @@ function octopus::util::get_arch() {

echo -n "${arch}"
}

function octopus::util::get_random_port_start() {
local offset="${1:-1}"
if [[ ${offset} -le 0 ]]; then
offset=1
fi

while true; do
random_port=$((RANDOM % 10000 + 50000))
for ((i = 0; i < offset; i++)); do
if nc -z 127.0.0.1 $((random_port + i)); then
random_port=0
break
fi
done

if [[ ${random_port} -ne 0 ]]; then
echo "${random_port}"
break
fi
done
}
2 changes: 1 addition & 1 deletion template/adaptor/Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13.9-buster
RUN apt-get update && \
apt-get install -y xz-utils unzip
apt-get install -y xz-utils unzip netcat

# -- for make rules
## install docker
Expand Down

0 comments on commit ddeae42

Please sign in to comment.