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
624dad3e
Commit
624dad3e
authored
Apr 06, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #576 from adamreese/feat/kube-up-config
feat(scripts): save kubeconfig on kube-up.sh
parents
cebc2c37
529e3859
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
11 deletions
+30
-11
kube-down.sh
scripts/kube-down.sh
+3
-3
kube-up.sh
scripts/kube-up.sh
+24
-5
kubectl.sh
scripts/kubectl.sh
+3
-3
No files found.
scripts/kube-down.sh
View file @
624dad3e
...
@@ -23,9 +23,9 @@ source "${HELM_ROOT}/scripts/common.sh"
...
@@ -23,9 +23,9 @@ source "${HELM_ROOT}/scripts/common.sh"
source
"
${
HELM_ROOT
}
/scripts/docker.sh"
source
"
${
HELM_ROOT
}
/scripts/docker.sh"
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_
HOST
=
${
KUBE_HOST
:-
$DOCKER_HOST_IP
}
KUBE_
MASTER_IP
=
${
KUBE_MASTER_IP
:-
$DOCKER_HOST_IP
}
KUBE_
HOST
=
${
KUBE_HOST
:-
localhost
}
KUBE_
MASTER_IP
=
${
KUBE_MASTER_IP
:-
localhost
}
KUBECTL
=
"kubectl -s
${
KUBE_
HOST
}
:
${
KUBE_PORT
}
"
KUBECTL
=
"kubectl -s
${
KUBE_
MASTER_IP
}
:
${
KUBE_PORT
}
"
delete_kube_resources
()
{
delete_kube_resources
()
{
echo
"Deleting resources in kubernetes..."
echo
"Deleting resources in kubernetes..."
...
...
scripts/kube-up.sh
View file @
624dad3e
...
@@ -26,9 +26,10 @@ source "${HELM_ROOT}/scripts/docker.sh"
...
@@ -26,9 +26,10 @@ source "${HELM_ROOT}/scripts/docker.sh"
K8S_VERSION
=
${
K8S_VERSION
:-
1
.2.0
}
K8S_VERSION
=
${
K8S_VERSION
:-
1
.2.0
}
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_HOST
=
${
KUBE_HOST
:-
$DOCKER_HOST_IP
}
KUBE_MASTER_IP
=
${
KUBE_MASTER_IP
:-
$DOCKER_HOST_IP
}
KUBE_HOST
=
${
KUBE_HOST
:-
localhost
}
KUBE_MASTER_IP
=
${
KUBE_MASTER_IP
:-
localhost
}
KUBECTL
=
"kubectl -s
${
KUBE_HOST
}
:
${
KUBE_PORT
}
"
KUBECTL
=
"kubectl -s
${
KUBE_MASTER_IP
}
:
${
KUBE_PORT
}
"
KUBE_CONTEXT
=
${
KUBE_CONTEXT
:-
docker
}
require_command
()
{
require_command
()
{
if
!
command
-v
"
$1
"
>
/dev/null 2>&1
;
then
if
!
command
-v
"
$1
"
>
/dev/null 2>&1
;
then
...
@@ -61,8 +62,10 @@ setup_iptables() {
...
@@ -61,8 +62,10 @@ setup_iptables() {
echo
"Adding iptables hackery for docker-machine..."
echo
"Adding iptables hackery for docker-machine..."
local
machine_ip
=
$(
docker-machine ip
"
$machine
"
)
local
machine_ip
=
$(
docker-machine ip
"
$machine
"
)
if
!
docker-machine ssh
"
${
machine
}
"
"sudo /usr/local/sbin/iptables -t nat -L -n"
|
grep
-q
"
${
machine_ip
}
"
|
grep
-q
":
${
KUBE_PORT
}
"
;
then
local
iptables_rule
=
"PREROUTING -p tcp -d
${
machine_ip
}
--dport
${
KUBE_PORT
}
-j DNAT --to-destination 127.0.0.1:
${
KUBE_PORT
}
"
docker-machine ssh
"
${
machine
}
"
"sudo /usr/local/sbin/iptables -t nat -I PREROUTING -p tcp -d
${
machine_ip
}
--dport
${
KUBE_PORT
}
-j DNAT --to-destination 127.0.0.1:
${
KUBE_PORT
}
"
if
!
docker-machine ssh
"
${
machine
}
"
"sudo /usr/local/sbin/iptables -t nat -C
${
iptables_rule
}
"
;
then
docker-machine ssh
"
${
machine
}
"
"sudo /usr/local/sbin/iptables -t nat -I
${
iptables_rule
}
"
fi
fi
}
}
...
@@ -150,6 +153,20 @@ spec:
...
@@ -150,6 +153,20 @@ spec:
EOF
EOF
}
}
# Generate kubeconfig data for the created cluster.
create_kubeconfig
()
{
local
cluster_args
=(
"--server=http://
${
KUBE_MASTER_IP
}
:
${
KUBE_PORT
}
"
"--insecure-skip-tls-verify=true"
)
kubectl config set-cluster
"
${
KUBE_CONTEXT
}
"
"
${
cluster_args
[@]
}
"
kubectl config set-context
"
${
KUBE_CONTEXT
}
"
--cluster
=
"
${
KUBE_CONTEXT
}
"
kubectl config use-context
"
${
KUBE_CONTEXT
}
"
echo
"Wrote config for
${
KUBE_CONTEXT
}
"
}
main
()
{
main
()
{
verify_prereqs
verify_prereqs
...
@@ -159,8 +176,10 @@ main() {
...
@@ -159,8 +176,10 @@ main() {
start_kubernetes
start_kubernetes
wait_for_kubernetes
wait_for_kubernetes
create_kube_system_namespace
create_kube_system_namespace
create_kube_dns
create_kube_dns
create_kubeconfig
$KUBECTL
cluster-info
$KUBECTL
cluster-info
}
}
...
...
scripts/kubectl.sh
View file @
624dad3e
...
@@ -21,10 +21,10 @@ source "${HELM_ROOT}/scripts/common.sh"
...
@@ -21,10 +21,10 @@ source "${HELM_ROOT}/scripts/common.sh"
source
"
${
HELM_ROOT
}
/scripts/docker.sh"
source
"
${
HELM_ROOT
}
/scripts/docker.sh"
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_PORT
=
${
KUBE_PORT
:-
8080
}
KUBE_
HOST
=
${
KUBE_HOST
:-
localhost
}
KUBE_
MASTER_IP
=
${
KUBE_MASTER_IP
:-
localhost
}
if
is_docker_machine
;
then
if
is_docker_machine
;
then
KUBE_
HOST
=
$(
docker-machine ip
"
$(
active_docker_machine
)
"
)
KUBE_
MASTER_IP
=
$(
docker-machine ip
"
$(
active_docker_machine
)
"
)
fi
fi
kubectl
-s
${
KUBE_
HOST
}
:
${
KUBE_PORT
}
"
$@
"
kubectl
-s
${
KUBE_
MASTER_IP
}
:
${
KUBE_PORT
}
"
$@
"
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