Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
d11dd488
Commit
d11dd488
authored
Apr 08, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #586 from adamreese/fix/kube-dns
fix(scripts): fix kube-dns
parents
a3db79a1
c5efa1cd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
194 additions
and
54 deletions
+194
-54
kube-system.yaml
scripts/cluster/kube-system.yaml
+4
-0
skydns.yaml
scripts/cluster/skydns.yaml
+137
-0
kube-down.sh
scripts/kube-down.sh
+9
-3
kube-up.sh
scripts/kube-up.sh
+44
-51
No files found.
scripts/cluster/kube-system.yaml
0 → 100644
View file @
d11dd488
apiVersion
:
v1
kind
:
Namespace
metadata
:
name
:
kube-system
scripts/cluster/skydns.yaml
0 → 100644
View file @
d11dd488
apiVersion
:
v1
kind
:
ReplicationController
metadata
:
name
:
kube-dns-v10
namespace
:
kube-system
labels
:
k8s-app
:
kube-dns
version
:
v10
kubernetes.io/cluster-service
:
"
true"
spec
:
replicas
:
1
selector
:
k8s-app
:
kube-dns
version
:
v10
template
:
metadata
:
labels
:
k8s-app
:
kube-dns
version
:
v10
kubernetes.io/cluster-service
:
"
true"
spec
:
containers
:
-
name
:
etcd
image
:
gcr.io/google_containers/etcd-amd64:2.2.1
resources
:
# keep request = limit to keep this container in guaranteed class
limits
:
cpu
:
100m
memory
:
50Mi
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.12
resources
:
# keep request = limit to keep this container in guaranteed class
limits
:
cpu
:
100m
memory
:
50Mi
requests
:
cpu
:
100m
memory
:
50Mi
args
:
# command = "/kube2sky"
-
--domain=cluster.local
-
name
:
skydns
image
:
gcr.io/google_containers/skydns:2015-10-13-8c72f8c
resources
:
# keep request = limit to keep this container in guaranteed class
limits
:
cpu
:
100m
memory
:
50Mi
requests
:
cpu
:
100m
memory
:
50Mi
args
:
# command = "/skydns"
-
-machines=http://127.0.0.1:4001
-
-addr=0.0.0.0:53
-
-ns-rotate=false
-
-domain=cluster.local.
ports
:
-
containerPort
:
53
name
:
dns
protocol
:
UDP
-
containerPort
:
53
name
:
dns-tcp
protocol
:
TCP
livenessProbe
:
httpGet
:
path
:
/healthz
port
:
8080
scheme
:
HTTP
initialDelaySeconds
:
30
timeoutSeconds
:
5
readinessProbe
:
httpGet
:
path
:
/healthz
port
:
8080
scheme
:
HTTP
initialDelaySeconds
:
1
timeoutSeconds
:
5
-
name
:
healthz
image
:
gcr.io/google_containers/exechealthz:1.0
resources
:
# keep request = limit to keep this container in guaranteed class
limits
:
cpu
:
10m
memory
:
20Mi
requests
:
cpu
:
10m
memory
:
20Mi
args
:
-
-cmd=nslookup kubernetes.default.svc.cluster.local 127.0.0.1 >/dev/null
-
-port=8080
ports
:
-
containerPort
:
8080
protocol
:
TCP
volumes
:
-
name
:
etcd-storage
emptyDir
:
{}
dnsPolicy
:
Default
# Don't use cluster DNS.
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
kube-dns
namespace
:
kube-system
labels
:
k8s-app
:
kube-dns
kubernetes.io/cluster-service
:
"
true"
kubernetes.io/name
:
"
KubeDNS"
spec
:
selector
:
k8s-app
:
kube-dns
clusterIP
:
10.0.0.10
ports
:
-
name
:
dns
port
:
53
protocol
:
UDP
-
name
:
dns-tcp
port
:
53
protocol
:
TCP
scripts/kube-down.sh
View file @
d11dd488
...
@@ -36,10 +36,11 @@ delete_kube_resources() {
...
@@ -36,10 +36,11 @@ delete_kube_resources() {
}
}
delete_hyperkube_containers
()
{
delete_hyperkube_containers
()
{
echo
"Stopping
main
kubelet..."
echo
"Stopping kubelet..."
docker stop helm_kubelet
>
/dev/null 2>&1
||
true
docker stop kubelet
>
/dev/null 2>&1
||
:
docker
rm
--force
--volumes
helm_kubelet
>
/dev/null 2>&1
||
true
docker
wait
kubelet
>
/dev/null 2>&1
||
:
docker
rm
--force
--volumes
kubelet
>
/dev/null 2>&1
||
:
echo
"Stopping remaining kubernetes containers..."
echo
"Stopping remaining kubernetes containers..."
...
@@ -49,6 +50,11 @@ delete_hyperkube_containers() {
...
@@ -49,6 +50,11 @@ delete_hyperkube_containers() {
docker
wait
$kube_containers
>
/dev/null 2>&1
docker
wait
$kube_containers
>
/dev/null 2>&1
docker
rm
--force
--volumes
$kube_containers
>
/dev/null 2>&1
docker
rm
--force
--volumes
$kube_containers
>
/dev/null 2>&1
fi
fi
echo
"Stopping etcd..."
docker stop etcd
>
/dev/null 2>&1
||
:
docker
wait
etcd
>
/dev/null 2>&1
||
:
docker
rm
--force
--volumes
etcd
>
/dev/null 2>&1
||
:
}
}
main
()
{
main
()
{
...
...
scripts/kube-up.sh
View file @
d11dd488
...
@@ -24,13 +24,14 @@ HELM_ROOT="${BASH_SOURCE[0]%/*}/.."
...
@@ -24,13 +24,14 @@ HELM_ROOT="${BASH_SOURCE[0]%/*}/.."
source
"
${
HELM_ROOT
}
/scripts/common.sh"
source
"
${
HELM_ROOT
}
/scripts/common.sh"
source
"
${
HELM_ROOT
}
/scripts/docker.sh"
source
"
${
HELM_ROOT
}
/scripts/docker.sh"
K8S_VERSION
=
${
K8S_VERSION
:-
1
.2.
0
}
K8S_VERSION
=
${
K8S_VERSION
:-
1
.2.
1
}
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_MASTER_IP
=
${
KUBE_MASTER_IP
:-
$DOCKER_HOST_IP
}
KUBE_MASTER_IP
=
${
KUBE_MASTER_IP
:-
$DOCKER_HOST_IP
}
KUBE_MASTER_IP
=
${
KUBE_MASTER_IP
:-
localhost
}
KUBE_MASTER_IP
=
${
KUBE_MASTER_IP
:-
localhost
}
KUBECTL
=
"kubectl -s
${
KUBE_MASTER_IP
}
:
${
KUBE_PORT
}
"
KUBE_CONTEXT
=
${
KUBE_CONTEXT
:-
docker
}
KUBE_CONTEXT
=
${
KUBE_CONTEXT
:-
docker
}
KUBECTL
=
"kubectl -s
${
KUBE_MASTER_IP
}
:
${
KUBE_PORT
}
"
require_command
()
{
require_command
()
{
if
!
command
-v
"
$1
"
>
/dev/null 2>&1
;
then
if
!
command
-v
"
$1
"
>
/dev/null 2>&1
;
then
error_exit
"Cannot find command
${
1
}
"
error_exit
"Cannot find command
${
1
}
"
...
@@ -72,31 +73,37 @@ setup_iptables() {
...
@@ -72,31 +73,37 @@ setup_iptables() {
start_kubernetes
()
{
start_kubernetes
()
{
echo
"Getting the party going..."
echo
"Getting the party going..."
#if docker ps --filter "name=helm_kubelet" >/dev/null; then
echo
"Starting etcd"
#error_exit "Kubernetes already running"
docker run
\
#fi
--name
=
etcd
\
--net
=
host
\
-d
\
gcr.io/google_containers/etcd:2.2.1
\
/usr/local/bin/etcd
\
--listen-client-urls
=
http://127.0.0.1:4001
\
--advertise-client-urls
=
http://127.0.0.1:4001
>
/dev/null 2>&1
echo
"Starting kubelet"
docker run
\
docker run
\
--name
=
helm_
kubelet
\
--name
=
kubelet
\
--volume
=
/:/rootfs:ro
\
--volume
=
/:/rootfs:ro
\
--volume
=
/sys:/sys:ro
\
--volume
=
/sys:/sys:ro
\
--volume
=
/var/lib/docker/:/var/lib/docker:rw
\
--volume
=
/var/lib/docker/:/var/lib/docker:rw
\
--volume
=
/var/lib/kubelet/:/var/lib/kubelet:rw
\
--volume
=
/var/run:/var/run:rw
\
--volume
=
/var/run:/var/run:rw
\
--volume
=
/var/lib/kubelet:/var/lib/kubelet:shared
\
--net
=
host
\
--net
=
host
\
--pid
=
host
\
--pid
=
host
\
--privileged
=
true
\
--privileged
=
true
\
-d
\
-d
\
gcr.io/google_containers/hyperkube-amd64:v
${
K8S_VERSION
}
\
gcr.io/google_containers/hyperkube-amd64:v
${
K8S_VERSION
}
\
/hyperkube kubelet
\
/hyperkube kubelet
\
--containerized
\
--hostname-override
=
"127.0.0.1"
\
--hostname-override
=
"127.0.0.1"
\
--address
=
"0.0.0.0"
\
--address
=
"0.0.0.0"
\
--api-servers
=
http://localhost:
${
KUBE_PORT
}
\
--api-servers
=
"http://localhost:
${
KUBE_PORT
}
"
\
--config
=
/etc/kubernetes/manifests-multi
\
--config
=
/etc/kubernetes/manifests
\
--cluster-dns
=
10.0.0.10
\
--cluster-dns
=
10.0.0.10
\
--cluster-domain
=
cluster.local
\
--cluster-domain
=
cluster.local
\
--allow-privileged
=
true
--v
=
2
>
/dev/null 2>&1
--allow-privileged
=
true
--v
=
2
}
}
wait_for_kubernetes
()
{
wait_for_kubernetes
()
{
...
@@ -110,47 +117,13 @@ wait_for_kubernetes() {
...
@@ -110,47 +117,13 @@ wait_for_kubernetes() {
create_kube_system_namespace
()
{
create_kube_system_namespace
()
{
echo
"Creating kube-system namespace..."
echo
"Creating kube-system namespace..."
$KUBECTL
create
-f
-
<<
EOF
$KUBECTL
create
-f
"
${
HELM_ROOT
}
/scripts/cluster/kube-system.yaml"
||
:
kind: Namespace
apiVersion: v1
metadata:
name: kube-system
labels:
name: kube-system
EOF
}
}
create_kube_dns
()
{
create_kube_dns
()
{
echo
"Setting up internal dns..."
echo
"Setting up internal dns..."
$KUBECTL
--namespace
=
kube-system create
-f
-
<<
EOF
$KUBECTL
create
-f
"
${
HELM_ROOT
}
/scripts/cluster/skydns.yaml"
apiVersion: v1
kind: Endpoints
metadata:
name: kube-dns
namespace: kube-system
subsets:
- addresses:
- ip:
$DOCKER_HOST_IP
ports:
- port: 53
protocol: UDP
name: dns
---
kind: Service
apiVersion: v1
metadata:
name: kube-dns
namespace: kube-system
spec:
clusterIP: 10.0.0.10
ports:
- name: dns
port: 53
protocol: UDP
EOF
}
}
# Generate kubeconfig data for the created cluster.
# Generate kubeconfig data for the created cluster.
...
@@ -167,8 +140,28 @@ create_kubeconfig() {
...
@@ -167,8 +140,28 @@ create_kubeconfig() {
echo
"Wrote config for
${
KUBE_CONTEXT
}
"
echo
"Wrote config for
${
KUBE_CONTEXT
}
"
}
}
# https://github.com/kubernetes/kubernetes/issues/23197
# code stolen from https://github.com/huggsboson/docker-compose-kubernetes/blob/SwitchToSharedMount/kube-up.sh
cleanup_volumes
()
{
local
machine
=
$(
active_docker_machine
)
if
[
-n
"
$machine
"
]
;
then
docker-machine ssh
$machine
"mount | grep -o 'on /var/lib/kubelet.* type' | cut -c 4- | rev | cut -c 6- | rev | sort -r | xargs --no-run-if-empty sudo umount"
docker-machine ssh
$machine
"sudo rm -Rf /var/lib/kubelet"
docker-machine ssh
$machine
"sudo mkdir -p /var/lib/kubelet"
docker-machine ssh
$machine
"sudo mount --bind /var/lib/kubelet /var/lib/kubelet"
docker-machine ssh
$machine
"sudo mount --make-shared /var/lib/kubelet"
else
mount |
grep
-o
'on /var/lib/kubelet.* type'
|
cut
-c
4- | rev |
cut
-c
6- | rev |
sort
-r
| xargs
--no-run-if-empty
sudo
umount
sudo rm
-Rf
/var/lib/kubelet
sudo mkdir
-p
/var/lib/kubelet
sudo
mount
--bind
/var/lib/kubelet /var/lib/kubelet
sudo
mount
--make-shared
/var/lib/kubelet
fi
}
main
()
{
main
()
{
verify_prereqs
verify_prereqs
cleanup_volumes
if
is_docker_machine
;
then
if
is_docker_machine
;
then
setup_iptables
setup_iptables
...
...
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