mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #30092 from mbruzek/juju-util-fixes
Automatic merge from submit-queue Juju util fixes The util.sh file was out of date and caused the kube-up script to error out. This work fixes #23198 ```release-note * Updating the util.sh for the juju provider kube-up.sh ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.kubernetes.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.kubernetes.io/reviews/kubernetes/kubernetes/30092) <!-- Reviewable:end -->
This commit is contained in:
commit
ea69570f61
1
.gitignore
vendored
1
.gitignore
vendored
@ -88,6 +88,7 @@ network_closure.sh
|
|||||||
|
|
||||||
# Juju Stuff
|
# Juju Stuff
|
||||||
/cluster/juju/charms/*
|
/cluster/juju/charms/*
|
||||||
|
/cluster/juju/bundles/local.yaml
|
||||||
|
|
||||||
# Downloaded Kubernetes binary release
|
# Downloaded Kubernetes binary release
|
||||||
/kubernetes/
|
/kubernetes/
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
services:
|
services:
|
||||||
kubernetes:
|
kubernetes:
|
||||||
charm: local:trusty/kubernetes
|
charm: __CHARM_DIR__/builds/kubernetes
|
||||||
annotations:
|
annotations:
|
||||||
"gui-x": "600"
|
"gui-x": "600"
|
||||||
"gui-y": "0"
|
"gui-y": "0"
|
||||||
expose: true
|
expose: true
|
||||||
num_units: 2
|
num_units: 2
|
||||||
etcd:
|
etcd:
|
||||||
charm: cs:~containers/trusty/etcd
|
charm: cs:~containers/etcd
|
||||||
annotations:
|
annotations:
|
||||||
"gui-x": "300"
|
"gui-x": "300"
|
||||||
"gui-y": "0"
|
"gui-y": "0"
|
||||||
@ -15,4 +15,4 @@ services:
|
|||||||
relations:
|
relations:
|
||||||
- - "kubernetes:etcd"
|
- - "kubernetes:etcd"
|
||||||
- "etcd:db"
|
- "etcd:db"
|
||||||
series: trusty
|
series: xenial
|
@ -17,13 +17,15 @@
|
|||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
out = check_output(['juju', 'status', 'kubernetes', '--format=yaml'])
|
|
||||||
|
cmd = ['juju', 'run', '--application', 'kubernetes', '--format=yaml', 'is-leader']
|
||||||
|
out = check_output(cmd)
|
||||||
try:
|
try:
|
||||||
parsed_output = yaml.safe_load(out)
|
parsed_output = yaml.safe_load(out)
|
||||||
model = parsed_output['services']['kubernetes']['units']
|
for unit in parsed_output:
|
||||||
for unit in model:
|
standard_out = unit['Stdout'].rstrip()
|
||||||
if 'workload-status' in model[unit].keys():
|
unit_id = unit['UnitId']
|
||||||
if 'leader' in model[unit]['workload-status']['message']:
|
if 'True' in standard_out:
|
||||||
print(unit)
|
print(unit_id)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -16,4 +16,4 @@ requires:
|
|||||||
etcd:
|
etcd:
|
||||||
interface: etcd
|
interface: etcd
|
||||||
series:
|
series:
|
||||||
- 'trusty'
|
- xenial
|
||||||
|
@ -38,7 +38,7 @@ function build-local() {
|
|||||||
# This used to build the kubernetes project. Now it rebuilds the charm(s)
|
# This used to build the kubernetes project. Now it rebuilds the charm(s)
|
||||||
# living in `cluster/juju/layers`
|
# living in `cluster/juju/layers`
|
||||||
|
|
||||||
charm build -o $JUJU_REPOSITORY -s trusty ${JUJU_PATH}/layers/kubernetes
|
charm build ${JUJU_PATH}/layers/kubernetes -o $JUJU_REPOSITORY -r --no-local-layers
|
||||||
}
|
}
|
||||||
|
|
||||||
function detect-master() {
|
function detect-master() {
|
||||||
@ -54,7 +54,7 @@ function detect-master() {
|
|||||||
function detect-nodes() {
|
function detect-nodes() {
|
||||||
# Run the Juju command that gets the minion private IP addresses.
|
# Run the Juju command that gets the minion private IP addresses.
|
||||||
local ipoutput
|
local ipoutput
|
||||||
ipoutput=$(juju run --service kubernetes "unit-get private-address" --format=json)
|
ipoutput=$(juju run --application kubernetes "unit-get private-address" --format=json)
|
||||||
# [
|
# [
|
||||||
# {"MachineId":"2","Stdout":"192.168.122.188\n","UnitId":"kubernetes/0"},
|
# {"MachineId":"2","Stdout":"192.168.122.188\n","UnitId":"kubernetes/0"},
|
||||||
# {"MachineId":"3","Stdout":"192.168.122.166\n","UnitId":"kubernetes/1"}
|
# {"MachineId":"3","Stdout":"192.168.122.166\n","UnitId":"kubernetes/1"}
|
||||||
@ -69,6 +69,9 @@ function detect-nodes() {
|
|||||||
function kube-up() {
|
function kube-up() {
|
||||||
build-local
|
build-local
|
||||||
|
|
||||||
|
# Replace the charm directory in the bundle.
|
||||||
|
sed "s|__CHARM_DIR__|${JUJU_REPOSITORY}|" < ${KUBE_BUNDLE_PATH}.base > ${KUBE_BUNDLE_PATH}
|
||||||
|
|
||||||
# The juju-deployer command will deploy the bundle and can be run
|
# The juju-deployer command will deploy the bundle and can be run
|
||||||
# multiple times to continue deploying the parts that fail.
|
# multiple times to continue deploying the parts that fail.
|
||||||
juju deploy ${KUBE_BUNDLE_PATH}
|
juju deploy ${KUBE_BUNDLE_PATH}
|
||||||
@ -88,7 +91,7 @@ function kube-up() {
|
|||||||
tar xfz ${KUBECTL_DIR}/kubectl_package.tar.gz -C ${KUBECTL_DIR}
|
tar xfz ${KUBECTL_DIR}/kubectl_package.tar.gz -C ${KUBECTL_DIR}
|
||||||
)
|
)
|
||||||
# Export the location of the kubectl configuration file.
|
# Export the location of the kubectl configuration file.
|
||||||
export KUBECONFIG="${KUBECTL_DIR}/config"
|
export KUBECONFIG="${KUBECTL_DIR}/kubeconfig"
|
||||||
}
|
}
|
||||||
|
|
||||||
function kube-down() {
|
function kube-down() {
|
||||||
@ -117,7 +120,7 @@ function sleep-status() {
|
|||||||
|
|
||||||
while [[ $i < $maxtime && -z $jujustatus ]]; do
|
while [[ $i < $maxtime && -z $jujustatus ]]; do
|
||||||
sleep 15
|
sleep 15
|
||||||
i+=15
|
i=$((i + 15))
|
||||||
jujustatus=$(${JUJU_PATH}/identify-leaders.py)
|
jujustatus=$(${JUJU_PATH}/identify-leaders.py)
|
||||||
export KUBE_MASTER_NAME=${jujustatus}
|
export KUBE_MASTER_NAME=${jujustatus}
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user