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
6d465c4d
Commit
6d465c4d
authored
Mar 10, 2015
by
Zach Loafman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5273 from zmerlynn/salt_drones
Remove dep on yaml for GCE startup
parents
d8c6e346
759e82c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
59 deletions
+33
-59
kube-env.py
cluster/gce/kube-env.py
+0
-31
util.sh
cluster/gce/util.sh
+33
-28
No files found.
cluster/gce/kube-env.py
deleted
100755 → 0
View file @
d8c6e346
#!/usr/bin/python
# Copyright 2015 Google Inc. All rights reserved.
#
# 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.
import
os
import
sys
import
yaml
def
mutate_env
(
path
,
var
,
value
):
# Load the existing arguments
if
os
.
path
.
exists
(
path
):
args
=
yaml
.
load
(
open
(
path
))
else
:
args
=
{}
args
[
var
]
=
value
yaml
.
dump
(
args
,
stream
=
open
(
path
,
'w'
),
default_flow_style
=
False
)
if
__name__
==
"__main__"
:
mutate_env
(
sys
.
argv
[
1
],
sys
.
argv
[
2
],
sys
.
argv
[
3
])
cluster/gce/util.sh
View file @
6d465c4d
...
...
@@ -418,13 +418,13 @@ function add-instance-metadata-from-file {
done
}
#
Given a yaml file, add or mutate the given env variable
#
Quote something appropriate for a yaml string.
#
# TODO(zmerlynn):
Yes, this is an O(n^2) build-up right now. If we end
#
up with so many environment variables feeding into Salt that this
#
matters, there's probably an issue...
function
add-to-env
{
${
KUBE_ROOT
}
/cluster/gce/kube-env.py
"
$1
"
"
$2
"
"
$3
"
# TODO(zmerlynn):
Note that this function doesn't so much "quote" as
#
"strip out quotes", and we really should be using a YAML library for
#
this, but PyYAML isn't shipped by default, and *rant rant rant ... SIGH*
function
yaml-quote
{
echo
"'
$(
echo
"
${
@
}
"
|
sed
-e
"s/'/''/g"
)
'
"
}
# $1: if 'true', we're building a master yaml, else a node
...
...
@@ -433,29 +433,34 @@ function build-kube-env {
local
file
=
$2
rm
-f
${
file
}
add-to-env
${
file
}
ENV_TIMESTAMP
"
$(
date
-uIs
)
"
# Just to track it
add-to-env
${
file
}
KUBERNETES_MASTER
"
${
master
}
"
add-to-env
${
file
}
INSTANCE_PREFIX
"
${
INSTANCE_PREFIX
}
"
add-to-env
${
file
}
NODE_INSTANCE_PREFIX
"
${
NODE_INSTANCE_PREFIX
}
"
add-to-env
${
file
}
SERVER_BINARY_TAR_URL
"
${
SERVER_BINARY_TAR_URL
}
"
add-to-env
${
file
}
SALT_TAR_URL
"
${
SALT_TAR_URL
}
"
add-to-env
${
file
}
PORTAL_NET
"
${
PORTAL_NET
}
"
add-to-env
${
file
}
ENABLE_CLUSTER_MONITORING
"
${
ENABLE_CLUSTER_MONITORING
:-
false
}
"
add-to-env
${
file
}
ENABLE_NODE_MONITORING
"
${
ENABLE_NODE_MONITORING
:-
false
}
"
add-to-env
${
file
}
ENABLE_CLUSTER_LOGGING
"
${
ENABLE_CLUSTER_LOGGING
:-
false
}
"
add-to-env
${
file
}
ENABLE_NODE_LOGGING
"
${
ENABLE_NODE_LOGGING
:-
false
}
"
add-to-env
${
file
}
LOGGING_DESTINATION
"
${
LOGGING_DESTINATION
:-}
"
add-to-env
${
file
}
ELASTICSEARCH_LOGGING_REPLICAS
"
${
ELASTICSEARCH_LOGGING_REPLICAS
:-}
"
add-to-env
${
file
}
ENABLE_CLUSTER_DNS
"
${
ENABLE_CLUSTER_DNS
:-
false
}
"
add-to-env
${
file
}
DNS_REPLICAS
"
${
DNS_REPLICAS
:-}
"
add-to-env
${
file
}
DNS_SERVER_IP
"
${
DNS_SERVER_IP
:-}
"
add-to-env
${
file
}
DNS_DOMAIN
"
${
DNS_DOMAIN
:-}
"
add-to-env
${
file
}
MASTER_HTPASSWD
"
${
MASTER_HTPASSWD
}
"
cat
>
$file
<<
EOF
ENV_TIMESTAMP:
$(
yaml-quote
$(
date
-uIs
))
KUBERNETES_MASTER:
$(
yaml-quote
${
master
})
INSTANCE_PREFIX:
$(
yaml-quote
${
INSTANCE_PREFIX
})
NODE_INSTANCE_PREFIX:
$(
yaml-quote
${
NODE_INSTANCE_PREFIX
})
SERVER_BINARY_TAR_URL:
$(
yaml-quote
${
SERVER_BINARY_TAR_URL
})
SALT_TAR_URL:
$(
yaml-quote
${
SALT_TAR_URL
})
PORTAL_NET:
$(
yaml-quote
${
PORTAL_NET
})
ENABLE_CLUSTER_MONITORING:
$(
yaml-quote
${
ENABLE_CLUSTER_MONITORING
:-
false
})
ENABLE_NODE_MONITORING:
$(
yaml-quote
${
ENABLE_NODE_MONITORING
:-
false
})
ENABLE_CLUSTER_LOGGING:
$(
yaml-quote
${
ENABLE_CLUSTER_LOGGING
:-
false
})
ENABLE_NODE_LOGGING:
$(
yaml-quote
${
ENABLE_NODE_LOGGING
:-
false
})
LOGGING_DESTINATION:
$(
yaml-quote
${
LOGGING_DESTINATION
:-})
ELASTICSEARCH_LOGGING_REPLICAS:
$(
yaml-quote
${
ELASTICSEARCH_LOGGING_REPLICAS
:-})
ENABLE_CLUSTER_DNS:
$(
yaml-quote
${
ENABLE_CLUSTER_DNS
:-
false
})
DNS_REPLICAS:
$(
yaml-quote
${
DNS_REPLICAS
:-})
DNS_SERVER_IP:
$(
yaml-quote
${
DNS_SERVER_IP
:-})
DNS_DOMAIN:
$(
yaml-quote
${
DNS_DOMAIN
:-})
MASTER_HTPASSWD:
$(
yaml-quote
${
MASTER_HTPASSWD
})
EOF
if
[[
"
${
master
}
"
!=
"true"
]]
;
then
add-to-env
${
file
}
KUBERNETES_MASTER_NAME
"
${
MASTER_NAME
}
"
add-to-env
${
file
}
ZONE
"
${
ZONE
}
"
add-to-env
${
file
}
EXTRA_DOCKER_OPTS
"
${
EXTRA_DOCKER_OPTS
}
"
add-to-env
${
file
}
ENABLE_DOCKER_REGISTRY_CACHE
"
${
ENABLE_DOCKER_REGISTRY_CACHE
:-
false
}
"
cat
>>
$file
<<
EOF
KUBERNETES_MASTER_NAME:
$(
yaml-quote
${
MASTER_NAME
})
ZONE:
$(
yaml-quote
${
ZONE
})
EXTRA_DOCKER_OPTS:
$(
yaml-quote
${
EXTRA_DOCKER_OPTS
})
ENABLE_DOCKER_REGISTRY_CACHE:
$(
yaml-quote
${
ENABLE_DOCKER_REGISTRY_CACHE
:-
false
})
EOF
fi
}
...
...
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