Skip to content

Commit 1313e14

Browse files
davejrtscotty-c
authored andcommitted
Kube tool (#91)
* weave updated * flannel complete * calico and clean up * Update other_params.rb * Update other_params.rb * adding service api back * adding service api back * adding service api back * fixing up typos * updates for kube_api_service_ip address * fixing bad variable name and unit test
1 parent 0e3623c commit 1313e14

File tree

7 files changed

+34
-28
lines changed

7 files changed

+34
-28
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ If you do not already have Docker installed on your workstation, install it [her
5252

5353
The kubetool docker image takes each of the parameters as environment variables. When run as follows it will output a `kubernetes.yaml` file in your current working directory:
5454
```
55-
docker run --rm -v $(pwd):/mnt -e OS=debian -e VERSION=1.9.2 -e CONTAINER_RUNTIME=docker -e CNI_PROVIDER=weave -e FQDN=kubernetes -e IP=172.17.10.101 -e BOOTSTRAP_CONTROLLER_IP=172.17.10.101 -e ETCD_INITIAL_CLUSTER="etcd-kube-master=http://172.17.10.101:2380" -e ETCD_IP="%{::ipaddress_enp0s8}" -e KUBE_API_ADVERTISE_ADDRESS="%{::ipaddress_enp0s8}" -e SERVICE_API_IP=10.96.0.1 -e INSTALL_DASHBOARD=true puppet/kubetool
55+
docker run --rm -v $(pwd):/mnt -e OS=debian -e VERSION=1.9.2 -e CONTAINER_RUNTIME=docker -e CNI_PROVIDER=weave -e FQDN=kubernetes -e IP=172.17.10.101 -e BOOTSTRAP_CONTROLLER_IP=172.17.10.101 -e ETCD_INITIAL_CLUSTER="etcd-kube-master=http://172.17.10.101:2380" -e ETCD_IP="%{::ipaddress_enp0s8}" -e KUBE_API_ADVERTISE_ADDRESS="%{::ipaddress_enp0s8}" -e INSTALL_DASHBOARD=true puppet/kubetool
5656
```
5757

5858
The parameters are:
@@ -66,7 +66,6 @@ The parameters are:
6666
* `BOOTSTRAP_CONTROLLER_IP`: the ip address of the controller puppet will use to create things like cluster role bindings, kube dns, and the Kubernetes dashboard.
6767
* `ETCD_INITIAL_CLUSTER`: the server addresses. When in production, include three, five, or seven nodes for etcd.
6868
* `ETCD_IP` and `KUBE_API_ADVERTISE_ADDRESS`: the IP each etcd/apiserver instance will use on each controller. We recommend passing the fact for the interface to be used by the cluster.
69-
* `SERVICE_API_IP`: the IP that the kubernetes service will be available on inside the cluster. Dependent on overlay network range.
7069
* `INSTALL_DASHBOARD`: a boolean to install the dashboard or not.
7170

7271
The kubetool creates a `kubernetes.yaml` file. To view the file contents on
@@ -480,13 +479,13 @@ Defaults to `undef` (don't specify for kube-apiserver). kube_tool sets this per
480479

481480
The cluster service IP to use for kube-dns.
482481

483-
Defaults to `10.96.0.10`
482+
Defaults to `undef`
484483

485-
#### `kube_api_ip`
484+
#### `kube_api_service_ip`
486485

487486
The cluster service IP to use for the kube api.
488487

489-
Defaults to `10.96.0.1`
488+
Defaults to `undef`
490489

491490
## Limitations
492491

manifests/init.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
# The service IP to use for kube-dns.
223223
# Defaults to 10.96.0.10
224224
#
225-
# [*kube_api_ip*]
225+
# [*kube_api_service_ip*]
226226
# The service IP to use for the kube api.
227227
# Defaults to 10.96.0.1
228228
#
@@ -294,7 +294,7 @@
294294
Boolean $taint_master = $kubernetes::params::taint_master,
295295
String $node_label = $kubernetes::params::node_label,
296296
String $kube_dns_ip = $kubernetes::params::kube_dns_ip,
297-
String $kube_api_ip = $kubernetes::params::kube_api_ip,
297+
String $kube_api_service_ip = $kubernetes::params::kube_api_service_ip,
298298
String $kube_proxy_version = $kubernetes::params::kube_proxy_version,
299299

300300
) inherits kubernetes::params {

manifests/params.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
$taint_master = true
6868
$node_label = $::hostname
6969
$cluster_service_cidr = undef
70-
$kube_api_ip = '10.96.0.1'
71-
$kube_dns_ip = '10.96.0.10'
70+
$kube_api_service_ip = undef
71+
$kube_dns_ip = undef
7272

7373
}

spec/classes/init_spec.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
context 'with controller => true and worker => true' do
1717
let(:params) do
1818
{ 'controller' => true,
19-
'worker' => true
19+
'worker' => true,
20+
'kube_api_service_ip' => '10.96.0.1',
21+
'kube_dns_ip' => '10.96.0.10',
2022
}
2123
end
2224

@@ -25,7 +27,10 @@
2527

2628
context 'with controller => true' do
2729
let(:params) do
28-
{ 'controller' => true }
30+
{ 'controller' => true,
31+
'kube_api_service_ip' => '10.96.0.1',
32+
'kube_dns_ip' => '10.96.0.10'
33+
}
2934
end
3035

3136
it { should contain_class('kubernetes') }
@@ -39,7 +44,10 @@
3944

4045
context 'with worker => true' do
4146
let(:params) do
42-
{ 'worker' => true}
47+
{ 'worker' => true,
48+
'kube_api_service_ip' => '10.96.0.1',
49+
'kube_dns_ip' => '10.96.0.10'
50+
}
4351
end
4452

4553
it { should contain_class('kubernetes') }

tooling/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ RUN set -x && \
2626

2727
WORKDIR /mnt
2828

29-
ENTRYPOINT ["sh", "-c", "/etc/k8s/kube_tool.rb -o ${OS} -v ${VERSION} -r ${CONTAINER_RUNTIME} -c ${CNI_PROVIDER} -f ${FQDN} -i ${IP} -b ${BOOTSTRAP_CONTROLLER_IP} -e ${ETCD_INITIAL_CLUSTER} -t ${ETCD_IP} -a ${KUBE_API_ADVERTISE_ADDRESS} -s ${SERVICE_API_IP} -d ${INSTALL_DASHBOARD}"]
29+
ENTRYPOINT ["sh", "-c", "/etc/k8s/kube_tool.rb -o ${OS} -v ${VERSION} -r ${CONTAINER_RUNTIME} -c ${CNI_PROVIDER} -f ${FQDN} -i ${IP} -b ${BOOTSTRAP_CONTROLLER_IP} -e ${ETCD_INITIAL_CLUSTER} -t ${ETCD_IP} -a ${KUBE_API_ADVERTISE_ADDRESS} -d ${INSTALL_DASHBOARD}"]

tooling/kube_tool.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
:etcd_initial_cluster => nil,
1818
:etcd_ip => nil,
1919
:kube_api_advertise_address => nil,
20-
:kube_api_cluster_address => nil,
21-
:install_dashboard => nil
20+
:install_dashboard => nil,
21+
:kube_api_service_ip => '10.96.0.1'
2222
}
2323

2424
parser = OptionParser.new do|opts|
@@ -63,10 +63,6 @@
6363
options[:kube_api_advertise_address] = api_address;
6464
end
6565

66-
opts.on('-s', '--cluster-api-address cluster_api_address', 'the ClusterIP address that kube api will listen on internally') do |cluster_api_address|
67-
options[:kube_api_cluster_address] = cluster_api_address;
68-
end
69-
7066
opts.on('-d', '--install-dashboard dashboard', 'install the kube dashboard') do |dashboard|
7167
options[:install_dashboard] = dashboard;
7268
end
@@ -82,10 +78,10 @@
8278

8379
class Kube_tool
8480
def build_hiera(hash)
85-
OtherParams.create(hash[:os], hash[:version], hash[:container_runtime], hash[:cni_provider], hash[:bootstrap_controller_ip], hash[:fqdn], hash[:etcd_initial_cluster], hash[:etcd_ip], hash[:kube_api_advertise_address], hash[:install_dashboard], hash[:kube_api_cluster_address])
81+
OtherParams.create(hash[:os], hash[:version], hash[:container_runtime], hash[:cni_provider], hash[:bootstrap_controller_ip], hash[:fqdn], hash[:etcd_initial_cluster], hash[:etcd_ip], hash[:kube_api_advertise_address], hash[:install_dashboard], hash[:kube_api_service_ip])
8682
PreChecks.checks
8783
CreateCerts.ca
88-
CreateCerts.api_servers(hash[:fqdn], hash[:ip], hash[:bootstrap_controller_ip], hash[:kube_api_cluster_address])
84+
CreateCerts.api_servers(hash[:fqdn], hash[:ip], hash[:bootstrap_controller_ip], hash[:kube_api_service_ip])
8985
PreChecks.checks
9086
CreateCerts.sa
9187
CreateCerts.admin

tooling/kube_tool/other_params.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class OtherParams
44

5-
def OtherParams.create(os, version, container_runtime, cni_provider, bootstrap_controller_ip, fqdn, etcd_initial_cluster, etcd_ip, kube_api_advertise_address, install_dashboard, cluster_api_address)
5+
def OtherParams.create(os, version, container_runtime, cni_provider, bootstrap_controller_ip, fqdn, etcd_initial_cluster, etcd_ip, kube_api_advertise_address, install_dashboard, kube_api_service_ip)
66
if install_dashboard.match('true')
77
install = true
88
else
@@ -16,19 +16,20 @@ def OtherParams.create(os, version, container_runtime, cni_provider, bootstrap_c
1616

1717
cni_cluster_cidr = nil
1818
cni_node_cidr = nil
19+
cni_node_cidr = true
20+
cluster_service_cidr = '10.96.0.0/12'
21+
kube_dns_ip = '10.96.0.10'
22+
1923
if cni_provider.match('weave')
2024
cni_network_provider = 'https://git.io/weave-kube-1.6'
25+
cni_cluster_cidr = '10.32.0.0/12'
2126
elsif
2227
cni_provider.match('flannel')
2328
cni_network_provider = 'https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml'
2429
cni_cluster_cidr = '10.244.0.0/16'
25-
cni_node_cidr = true
2630
elsif cni_provider.match('calico')
27-
cni_network_provider = 'https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml'
31+
cni_network_provider = 'https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml'
2832
cni_cluster_cidr = '192.168.0.0/16'
29-
cni_node_cidr = true
30-
elsif cni_provider.match('romana')
31-
cni_network_provider = 'https://raw.githubusercontent.com/romana/romana/master/containerize/specs/romana-kubeadm.yml'
3233
end
3334

3435
data = Hash.new
@@ -38,13 +39,15 @@ def OtherParams.create(os, version, container_runtime, cni_provider, bootstrap_c
3839
data['kubernetes::cni_network_provider'] = cni_network_provider
3940
data['kubernetes::cni_cluster_cidr'] = cni_cluster_cidr
4041
data['kubernetes::cni_node_cidr'] = cni_node_cidr
42+
data['kubernetes::cluster_service_cidr'] = cluster_service_cidr
4143
data['kubernetes::kubernetes_fqdn'] = fqdn
4244
data['kubernetes::bootstrap_controller_ip'] = bootstrap_controller_ip
4345
data['kubernetes::etcd_initial_cluster'] = etcd_initial_cluster
4446
data['kubernetes::etcd_ip'] = etcd_ip
4547
data['kubernetes::kube_api_advertise_address'] = kube_api_advertise_address
4648
data['kubernetes::install_dashboard'] = install
47-
data['kubernetes::kube_api_ip'] = cluster_api_address
49+
data['kubernetes::kube_api_service_ip'] = kube_api_service_ip
50+
data['kubernetes::kube_dns_ip'] = kube_dns_ip
4851
File.open("kubernetes.yaml", "w+") { |file| file.write(data.to_yaml) }
4952

5053
end

0 commit comments

Comments
 (0)