@@ -22,6 +22,7 @@ source "$(dirname "${BASH_SOURCE}")/util.sh"
22
22
23
23
ROOT_DIR=" $( cd " $( dirname " $0 " ) /.." ; pwd) "
24
24
WORKDIR=$( mktemp -d)
25
+ trap-add ' rm -rf "${WORKDIR}"' EXIT
25
26
NS=" ${KUBEFED_NAMESPACE:- kube-federation-system} "
26
27
CHART_FEDERATED_PROPAGATION_DIR=" ${CHART_FEDERATED_PROPAGATION_DIR:- charts/ kubefed} "
27
28
TEMP_CRDS_YAML=" /tmp/kubefed-crds.yaml"
@@ -36,13 +37,6 @@ if [ "${OS}" == "Darwin" ];then
36
37
SED=gsed
37
38
fi
38
39
39
- # Check for existence of kube-apiserver and etcd binaries in bin directory
40
- if [[ ! -f ${ROOT_DIR} /bin/etcd || ! -f ${ROOT_DIR} /bin/kube-apiserver ]];
41
- then
42
- echo " Missing 'etcd' and/or 'kube-apiserver' binaries in bin directory. Call './scripts/download-binaries.sh' to download them first"
43
- exit 1
44
- fi
45
-
46
40
# Remove existing generated crds to ensure that stale content doesn't linger.
47
41
rm -f ./config/crds/* .yaml
48
42
59
53
60
54
mv ${TEMP_CRDS_YAML} ./charts/kubefed/charts/controllermanager/crds/crds.yaml
61
55
62
- # Generate kubeconfig to access kube-apiserver. It is cleaned when script is done.
63
- cat << EOF > ${WORKDIR} /kubeconfig
64
- apiVersion: v1
65
- clusters:
66
- - cluster:
67
- server: 127.0.0.1:8080
68
- name: development
69
- contexts:
70
- - context:
71
- cluster: development
72
- user: ""
73
- name: kubefed
74
- current-context: ""
75
- kind: Config
76
- preferences: {}
77
- users: []
78
- EOF
79
-
80
- # Start kube-apiserver to generate CRDs
81
- ${ROOT_DIR} /bin/etcd --data-dir ${WORKDIR} --log-output stdout > ${WORKDIR} /etcd.log 2>&1 &
82
- util::wait-for-condition ' etcd' " curl http://127.0.0.1:2379/version &> /dev/null" 30
83
-
84
- ${ROOT_DIR} /bin/kube-apiserver --etcd-servers=http://127.0.0.1:2379 --service-cluster-ip-range=10.0.0.0/16 --cert-dir=${WORKDIR} 2> ${WORKDIR} /kube-apiserver.log &
85
- util::wait-for-condition ' kube-apiserver' " kubectl --kubeconfig ${WORKDIR} /kubeconfig --context kubefed get --raw=/healthz &> /dev/null" 60
56
+ declare -rx KUBECONFIG=" ${WORKDIR} /kubeconfig"
57
+ kind create cluster --name=kubefed-dev
58
+ trap-add ' kind delete cluster --name=kubefed-dev' EXIT
86
59
87
60
# Generate YAML templates to enable resource propagation for helm chart.
88
61
echo -n > ${CHART_FEDERATED_PROPAGATION_DIR} /templates/federatedtypeconfig.yaml
89
62
echo -n > ${CHART_FEDERATED_PROPAGATION_DIR} /crds/crds.yaml
90
63
for filename in ./config/enabletypedirectives/* .yaml; do
91
64
full_name=${CHART_FEDERATED_PROPAGATION_DIR} /templates/$( basename $filename )
92
65
93
- ./bin/kubefedctl --kubeconfig ${WORKDIR} /kubeconfig enable -f " ${filename} " --kubefed-namespace=" ${NS} " --host-cluster-context kubefed - o yaml > ${full_name}
66
+ ./bin/kubefedctl --kubeconfig ${WORKDIR} /kubeconfig enable -f " ${filename} " --kubefed-namespace=" ${NS} " -o yaml > ${full_name}
94
67
$SED -n ' /^---/,/^---/p' ${full_name} >> ${CHART_FEDERATED_PROPAGATION_DIR} /templates/federatedtypeconfig.yaml
95
68
$SED -i ' $d' ${CHART_FEDERATED_PROPAGATION_DIR} /templates/federatedtypeconfig.yaml
96
69
@@ -101,7 +74,4 @@ for filename in ./config/enabletypedirectives/*.yaml; do
101
74
done
102
75
103
76
# Clean kube-apiserver daemons and temporary files
104
- kill %1 # etcd
105
- kill %2 # kube-apiserver
106
- rm -fr ${WORKDIR}
107
77
echo " Helm chart synced successfully"
0 commit comments