Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
34dca937
Commit
34dca937
authored
Aug 02, 2016
by
Matt Bruzek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replacing skydns with kubedns for the juju cluster. #29720
parent
81ab15ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
90 deletions
+103
-90
k8s.py
cluster/juju/layers/kubernetes/reactive/k8s.py
+40
-29
kubedns-rc.yaml
cluster/juju/layers/kubernetes/templates/kubedns-rc.yaml
+44
-60
kubedns-svc.yaml
cluster/juju/layers/kubernetes/templates/kubedns-svc.yaml
+19
-1
No files found.
cluster/juju/layers/kubernetes/reactive/k8s.py
View file @
34dca937
...
@@ -131,36 +131,47 @@ def ca():
...
@@ -131,36 +131,47 @@ def ca():
@when
(
'kubelet.available'
,
'leadership.is_leader'
)
@when
(
'kubelet.available'
,
'leadership.is_leader'
)
@when_not
(
'skydns.available'
)
@when_not
(
'
kubedns.available'
,
'
skydns.available'
)
def
launch_
sky
dns
():
def
launch_dns
():
'''Create the "kube-system" namespace, the
skydns resource controller, and
'''Create the "kube-system" namespace, the
kubedns resource controller,
the sky
dns service. '''
and the kube
dns service. '''
hookenv
.
log
(
'Creating kubernetes
sky
dns on the master node.'
)
hookenv
.
log
(
'Creating kubernetes
kube
dns on the master node.'
)
# Only launch and track this state on the leader.
# Only launch and track this state on the leader.
# Launching duplicate
Sky
DNS rc will raise an error
# Launching duplicate
kube
DNS rc will raise an error
# Run a command to check if the apiserver is responding.
# Run a command to check if the apiserver is responding.
return_code
=
call
(
split
(
'kubectl cluster-info'
))
return_code
=
call
(
split
(
'kubectl cluster-info'
))
if
return_code
!=
0
:
if
return_code
!=
0
:
hookenv
.
log
(
'kubectl command failed, waiting for apiserver to start.'
)
hookenv
.
log
(
'kubectl command failed, waiting for apiserver to start.'
)
remove_state
(
'
sky
dns.available'
)
remove_state
(
'
kube
dns.available'
)
# Return without setting
sky
dns.available so this method will retry.
# Return without setting
kube
dns.available so this method will retry.
return
return
# Check for the "kube-system" namespace.
# Check for the "kube-system" namespace.
return_code
=
call
(
split
(
'kubectl get namespace kube-system'
))
return_code
=
call
(
split
(
'kubectl get namespace kube-system'
))
if
return_code
!=
0
:
if
return_code
!=
0
:
# Create the kube-system namespace that is used by the
sky
dns files.
# Create the kube-system namespace that is used by the
kube
dns files.
check_call
(
split
(
'kubectl create namespace kube-system'
))
check_call
(
split
(
'kubectl create namespace kube-system'
))
# Check for the
sky
dns replication controller.
# Check for the
kube
dns replication controller.
return_code
=
call
(
split
(
'kubectl get -f files/manifests/
skydns-rc.y
ml'
))
return_code
=
call
(
split
(
'kubectl get -f files/manifests/
kubedns-rc.ya
ml'
))
if
return_code
!=
0
:
if
return_code
!=
0
:
# Create the
sky
dns replication controller from the rendered file.
# Create the
kube
dns replication controller from the rendered file.
check_call
(
split
(
'kubectl create -f files/manifests/
skydns-rc.y
ml'
))
check_call
(
split
(
'kubectl create -f files/manifests/
kubedns-rc.ya
ml'
))
# Check for the
sky
dns service.
# Check for the
kube
dns service.
return_code
=
call
(
split
(
'kubectl get -f files/manifests/
skydns-svc.y
ml'
))
return_code
=
call
(
split
(
'kubectl get -f files/manifests/
kubedns-svc.ya
ml'
))
if
return_code
!=
0
:
if
return_code
!=
0
:
# Create the skydns service from the rendered file.
# Create the kubedns service from the rendered file.
check_call
(
split
(
'kubectl create -f files/manifests/skydns-svc.yml'
))
check_call
(
split
(
'kubectl create -f files/manifests/kubedns-svc.yaml'
))
set_state
(
'skydns.available'
)
set_state
(
'kubedns.available'
)
@when
(
'skydns.available'
,
'leadership.is_leader'
)
def
convert_to_kubedns
():
'''Delete the skydns containers to make way for the kubedns containers.'''
hookenv
.
log
(
'Deleteing the old skydns deployment.'
)
# Delete the skydns replication controller.
return_code
=
call
(
split
(
'kubectl delete rc kube-dns-v11'
))
# Delete the skydns service.
return_code
=
call
(
split
(
'kubectl delete svc kube-dns'
))
remove_state
(
'skydns.available'
)
@when
(
'docker.available'
)
@when
(
'docker.available'
)
...
@@ -297,11 +308,11 @@ def gather_sdn_data():
...
@@ -297,11 +308,11 @@ def gather_sdn_data():
else
:
else
:
# There is no SDN cider fall back to the kubernetes config cidr option.
# There is no SDN cider fall back to the kubernetes config cidr option.
pillar
[
'dns_server'
]
=
get_dns_ip
(
hookenv
.
config
()
.
get
(
'cidr'
))
pillar
[
'dns_server'
]
=
get_dns_ip
(
hookenv
.
config
()
.
get
(
'cidr'
))
# The pillar['dns_server'] value is used the
skydns-svc.y
ml file.
# The pillar['dns_server'] value is used the
kubedns-svc.ya
ml file.
pillar
[
'dns_replicas'
]
=
1
pillar
[
'dns_replicas'
]
=
1
# The pillar['dns_domain'] value is u
ed in the skydns-rc.y
ml
# The pillar['dns_domain'] value is u
sed in the kubedns-rc.ya
ml
pillar
[
'dns_domain'
]
=
hookenv
.
config
()
.
get
(
'dns_domain'
)
pillar
[
'dns_domain'
]
=
hookenv
.
config
()
.
get
(
'dns_domain'
)
# Use a 'pillar' dictionary so we can reuse the upstream
sky
dns templates.
# Use a 'pillar' dictionary so we can reuse the upstream
kube
dns templates.
sdn_data
[
'pillar'
]
=
pillar
sdn_data
[
'pillar'
]
=
pillar
return
sdn_data
return
sdn_data
...
@@ -400,14 +411,14 @@ def render_files(reldata=None):
...
@@ -400,14 +411,14 @@ def render_files(reldata=None):
# Render the files/manifests/master.json that contains parameters for
# Render the files/manifests/master.json that contains parameters for
# the apiserver, controller, and controller-manager
# the apiserver, controller, and controller-manager
render
(
'master.json'
,
target
,
context
)
render
(
'master.json'
,
target
,
context
)
# Source: ...
master/
cluster/addons/dns/skydns-svc.yaml.in
# Source: ...cluster/addons/dns/skydns-svc.yaml.in
target
=
os
.
path
.
join
(
rendered_manifest_dir
,
'
skydns-svc.y
ml'
)
target
=
os
.
path
.
join
(
rendered_manifest_dir
,
'
kubedns-svc.ya
ml'
)
# Render files/kubernetes/
skydns-svc.yaml for Sky
DNS service.
# Render files/kubernetes/
kubedns-svc.yaml for the
DNS service.
render
(
'
skydns-svc.y
ml'
,
target
,
context
)
render
(
'
kubedns-svc.ya
ml'
,
target
,
context
)
# Source: ...
master/
cluster/addons/dns/skydns-rc.yaml.in
# Source: ...cluster/addons/dns/skydns-rc.yaml.in
target
=
os
.
path
.
join
(
rendered_manifest_dir
,
'
skydns-rc.y
ml'
)
target
=
os
.
path
.
join
(
rendered_manifest_dir
,
'
kubedns-rc.ya
ml'
)
# Render files/kubernetes/
skydns-rc.yaml for Sky
DNS pod.
# Render files/kubernetes/
kubedns-rc.yaml for the
DNS pod.
render
(
'
skydns-rc.y
ml'
,
target
,
context
)
render
(
'
kubedns-rc.ya
ml'
,
target
,
context
)
def
status_set
(
level
,
message
):
def
status_set
(
level
,
message
):
...
...
cluster/juju/layers/kubernetes/templates/
skydns-rc.y
ml
→
cluster/juju/layers/kubernetes/templates/
kubedns-rc.ya
ml
View file @
34dca937
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file should be kept in sync with cluster/images/hyperkube/dns-rc.yaml
# Warning: This is a file generated from the base underscore template file: skydns-rc.yaml.base
apiVersion
:
v1
apiVersion
:
v1
kind
:
ReplicationController
kind
:
ReplicationController
metadata
:
metadata
:
name
:
kube-dns-v1
1
name
:
kube-dns-v1
8
namespace
:
kube-system
namespace
:
kube-system
labels
:
labels
:
k8s-app
:
kube-dns
k8s-app
:
kube-dns
version
:
v1
1
version
:
v1
8
kubernetes.io/cluster-service
:
"
true"
kubernetes.io/cluster-service
:
"
true"
spec
:
spec
:
replicas
:
{{
pillar
[
'
dns_replicas'
]
}}
replicas
:
{{
pillar
[
'
dns_replicas'
]
}}
selector
:
selector
:
k8s-app
:
kube-dns
k8s-app
:
kube-dns
version
:
v1
1
version
:
v1
8
template
:
template
:
metadata
:
metadata
:
labels
:
labels
:
k8s-app
:
kube-dns
k8s-app
:
kube-dns
version
:
v1
1
version
:
v1
8
kubernetes.io/cluster-service
:
"
true"
kubernetes.io/cluster-service
:
"
true"
spec
:
spec
:
containers
:
containers
:
-
name
:
etcd
-
name
:
kubedns
image
:
gcr.io/google_containers/
etcd-{{ arch }}:2.2.1
image
:
gcr.io/google_containers/
kubedns-{{ arch }}:1.6
resources
:
resources
:
# TODO: Set memory limits when we've profiled the container for large
# TODO: Set memory limits when we've profiled the container for large
# clusters, then set request = limit to keep this container in
# clusters, then set request = limit to keep this container in
...
@@ -29,37 +47,10 @@ spec:
...
@@ -29,37 +47,10 @@ spec:
# "burstable" category so the kubelet doesn't backoff from restarting it.
# "burstable" category so the kubelet doesn't backoff from restarting it.
limits
:
limits
:
cpu
:
100m
cpu
:
100m
memory
:
500Mi
requests
:
cpu
:
100m
memory
:
50Mi
command
:
-
/usr/local/bin/etcd
-
-data-dir
-
/var/etcd/data
-
-listen-client-urls
-
http://127.0.0.1:2379,http://127.0.0.1:4001
-
-advertise-client-urls
-
http://127.0.0.1:2379,http://127.0.0.1:4001
-
-initial-cluster-token
-
skydns-etcd
volumeMounts
:
-
name
:
etcd-storage
mountPath
:
/var/etcd/data
-
name
:
kube2sky
image
:
gcr.io/google_containers/kube2sky:1.14
resources
:
# TODO: Set memory limits when we've profiled the container for large
# clusters, then set request = limit to keep this container in
# guaranteed class. Currently, this container falls into the
# "burstable" category so the kubelet doesn't backoff from restarting it.
limits
:
cpu
:
100m
# Kube2sky watches all pods.
memory
:
200Mi
memory
:
200Mi
requests
:
requests
:
cpu
:
100m
cpu
:
100m
memory
:
5
0Mi
memory
:
10
0Mi
livenessProbe
:
livenessProbe
:
httpGet
:
httpGet
:
path
:
/healthz
path
:
/healthz
...
@@ -79,28 +70,23 @@ spec:
...
@@ -79,28 +70,23 @@ spec:
initialDelaySeconds
:
30
initialDelaySeconds
:
30
timeoutSeconds
:
5
timeoutSeconds
:
5
args
:
args
:
# command = "/kube2sky"
# command = "/kube-dns"
-
--domain={{ pillar['dns_domain'] }}
-
--domain={{ pillar['dns_domain'] }}.
-
--kube-master-url=http://{{ private_address }}:8080
-
--dns-port=10053
-
name
:
skydns
{{
pillar
[
'
federations_domain_map'
]
}}
image
:
gcr.io/google_containers/skydns:2015-10-13-8c72f8c
ports
:
resources
:
-
containerPort
:
10053
# TODO: Set memory limits when we've profiled the container for large
name
:
dns-local
# clusters, then set request = limit to keep this container in
protocol
:
UDP
# guaranteed class. Currently, this container falls into the
-
containerPort
:
10053
# "burstable" category so the kubelet doesn't backoff from restarting it.
name
:
dns-tcp-local
limits
:
protocol
:
TCP
cpu
:
100m
-
name
:
dnsmasq
memory
:
200Mi
image
:
gcr.io/google_containers/kube-dnsmasq-{{ arch }}:1.3
requests
:
cpu
:
100m
memory
:
50Mi
args
:
args
:
# command = "/skydns"
-
--cache-size=1000
-
-machines=http://127.0.0.1:4001
-
--no-resolv
-
-addr=0.0.0.0:53
-
--server=127.0.0.1#10053
-
-ns-rotate=false
-
-domain={{ pillar['dns_domain'] }}.
ports
:
ports
:
-
containerPort
:
53
-
containerPort
:
53
name
:
dns
name
:
dns
...
@@ -109,7 +95,7 @@ spec:
...
@@ -109,7 +95,7 @@ spec:
name
:
dns-tcp
name
:
dns-tcp
protocol
:
TCP
protocol
:
TCP
-
name
:
healthz
-
name
:
healthz
image
:
gcr.io/google_containers/exechealthz:1.0
image
:
gcr.io/google_containers/exechealthz
-{{ arch }}
:1.0
resources
:
resources
:
# keep request = limit to keep this container in guaranteed class
# keep request = limit to keep this container in guaranteed class
limits
:
limits
:
...
@@ -119,12 +105,10 @@ spec:
...
@@ -119,12 +105,10 @@ spec:
cpu
:
10m
cpu
:
10m
memory
:
20Mi
memory
:
20Mi
args
:
args
:
-
-cmd=nslookup kubernetes.default.svc.{{ pillar['dns_domain'] }} 127.0.0.1 >/dev/null
-
-cmd=nslookup kubernetes.default.svc.{{ pillar['dns_domain'] }} 127.0.0.1 >/dev/null
&& nslookup kubernetes.default.svc.{{ pillar['dns_domain'] }} 127.0.0.1:10053 >/dev/null
-
-port=8080
-
-port=8080
-
-quiet
ports
:
ports
:
-
containerPort
:
8080
-
containerPort
:
8080
protocol
:
TCP
protocol
:
TCP
volumes
:
-
name
:
etcd-storage
emptyDir
:
{}
dnsPolicy
:
Default
# Don't use cluster DNS.
dnsPolicy
:
Default
# Don't use cluster DNS.
cluster/juju/layers/kubernetes/templates/
skydns-svc.y
ml
→
cluster/juju/layers/kubernetes/templates/
kubedns-svc.ya
ml
View file @
34dca937
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file should be kept in sync with cluster/images/hyperkube/dns-svc.yaml
# Warning: This is a file generated from the base underscore template file: skydns-svc.yaml.base
apiVersion
:
v1
apiVersion
:
v1
kind
:
Service
kind
:
Service
metadata
:
metadata
:
...
@@ -10,7 +28,7 @@ metadata:
...
@@ -10,7 +28,7 @@ metadata:
spec
:
spec
:
selector
:
selector
:
k8s-app
:
kube-dns
k8s-app
:
kube-dns
clusterIP
:
{{
pillar
[
'
dns_server'
]
}}
clusterIP
:
{{
pillar
[
'
dns_server'
]
}}
ports
:
ports
:
-
name
:
dns
-
name
:
dns
port
:
53
port
:
53
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment