Skip to content

Commit

Permalink
k8s/script: allow parallelizing custom script without clear-containers (
Browse files Browse the repository at this point in the history
Azure#2067)

Signed-off-by: Jess Frazelle <[email protected]>
(cherry picked from commit cdd2832)
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Feb 15, 2018
1 parent 5656638 commit a6c6f4f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
28 changes: 19 additions & 9 deletions parts/k8s/kubernetesmastercustomscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Master only secrets
# APISERVER_PRIVATE_KEY CA_CERTIFICATE CA_PRIVATE_KEY MASTER_FQDN KUBECONFIG_CERTIFICATE
# KUBECONFIG_KEY ETCD_SERVER_CERTIFICATE ETCD_SERVER_PRIVATE_KEY ETCD_CLIENT_CERTIFICATE ETCD_CLIENT_PRIVATE_KEY
# KUBECONFIG_KEY ETCD_SERVER_CERTIFICATE ETCD_SERVER_PRIVATE_KEY ETCD_CLIENT_CERTIFICATE ETCD_CLIENT_PRIVATE_KEY
# ETCD_PEER_CERTIFICATES ETCD_PEER_PRIVATE_KEYS ADMINUSER MASTER_INDEX

# Find distro name via ID value in releases files and upcase
Expand Down Expand Up @@ -59,7 +59,7 @@ ensureRunCommandCompleted()
echo `date`,`hostname`, startscript>>/opt/m

# A delay to start the kubernetes processes is necessary
# if a reboot is required. Otherwise, the agents will encounter issue:
# if a reboot is required. Otherwise, the agents will encounter issue:
# https://github.com/kubernetes/kubernetes/issues/41185
REBOOTREQUIRED=false

Expand Down Expand Up @@ -621,7 +621,7 @@ function writeKubeConfig() {
chown $ADMINUSER:$ADMINUSER $KUBECONFIGFILE
chmod 700 $KUBECONFIGDIR
chmod 600 $KUBECONFIGFILE

# disable logging after secret output
set +x
echo "
Expand Down Expand Up @@ -649,18 +649,23 @@ users:
set -x
}

ensureRunCommandCompleted
echo `date`,`hostname`, RunCmdCompleted>>/opt/m
if [[ "$CONTAINER_RUNTIME" == "clear-containers" ]]; then
# If the container runtime is "clear-containers" we need to ensure the
# run command is completed _before_ we start installing all the dependencies
# for clear-containers to make sure there is not a dpkg lock.
ensureRunCommandCompleted
echo `date`,`hostname`, RunCmdCompleted>>/opt/m
fi

if [[ $OS == $UBUNTU_OS_NAME ]]; then
# make sure walinuxagent doesn't get updated in the middle of running this script
apt-mark hold walinuxagent
fi

# master and node
echo `date`,`hostname`, EnsureDockerStart>>/opt/m
echo `date`,`hostname`, EnsureDockerStart>>/opt/m
ensureDocker
echo `date`,`hostname`, configNetworkPolicyStart>>/opt/m
echo `date`,`hostname`, configNetworkPolicyStart>>/opt/m
configNetworkPolicy
if [[ "$CONTAINER_RUNTIME" == "clear-containers" ]]; then
# Ensure we can nest virtualization
Expand All @@ -677,12 +682,17 @@ echo `date`,`hostname`, ensureCRIOStart>>/opt/m
ensureCRIO
echo `date`,`hostname`, ensureKubeletStart>>/opt/m
ensureKubelet
echo `date`,`hostname`, extractKubctlStart>>/opt/m
echo `date`,`hostname`, extractKubctlStart>>/opt/m
extractKubectl
echo `date`,`hostname`, ensureJournalStart>>/opt/m
echo `date`,`hostname`, ensureJournalStart>>/opt/m
ensureJournal
echo `date`,`hostname`, ensureJournalDone>>/opt/m

# On all other runtimes, but "clear-containers" we can ensure the run command
# completed here to allow for parallelizing the custom script
ensureRunCommandCompleted
echo `date`,`hostname`, RunCmdCompleted>>/opt/m

# master only
if [[ ! -z "${APISERVER_PRIVATE_KEY}" ]]; then
writeKubeConfig
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/vlabs/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,13 @@ func Test_Properties_ValidateContainerRuntime(t *testing.T) {
p.OrchestratorProfile = &OrchestratorProfile{}
p.OrchestratorProfile.OrchestratorType = Kubernetes

for _, policy := range ContainerRuntimeValues {
for _, runtime := range ContainerRuntimeValues {
p.OrchestratorProfile.KubernetesConfig = &KubernetesConfig{}
p.OrchestratorProfile.KubernetesConfig.NetworkPolicy = policy
p.OrchestratorProfile.KubernetesConfig.ContainerRuntime = runtime
if err := p.validateContainerRuntime(); err != nil {
t.Errorf(
"should not error on containerRuntime=\"%s\"",
policy,
runtime,
)
}
}
Expand Down

0 comments on commit a6c6f4f

Please sign in to comment.