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
6a880b25
Commit
6a880b25
authored
Aug 22, 2018
by
Lantao Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support extra prune resources in kube-addon-manager.
Signed-off-by:
Lantao Liu
<
lantaol@google.com
>
parent
70e7a7d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
3 deletions
+50
-3
kube-addons.sh
cluster/addons/addon-manager/kube-addons.sh
+44
-2
configure-helper.sh
cluster/gce/gci/configure-helper.sh
+3
-1
kube-addon-manager.yaml
cluster/gce/manifests/kube-addon-manager.yaml
+3
-0
No files found.
cluster/addons/addon-manager/kube-addons.sh
View file @
6a880b25
...
@@ -28,6 +28,29 @@
...
@@ -28,6 +28,29 @@
KUBECTL
=
${
KUBECTL_BIN
:-
/usr/local/bin/kubectl
}
KUBECTL
=
${
KUBECTL_BIN
:-
/usr/local/bin/kubectl
}
KUBECTL_OPTS
=
${
KUBECTL_OPTS
:-}
KUBECTL_OPTS
=
${
KUBECTL_OPTS
:-}
# KUBECTL_PRUNE_WHITELIST is a list of resources whitelisted by
# default.
# This is currently the same with the default in:
# https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/apply.go
KUBECTL_PRUNE_WHITELIST
=(
core/v1/ConfigMap
core/v1/Endpoints
core/v1/Namespace
core/v1/PersistentVolumeClaim
core/v1/PersistentVolume
core/v1/Pod
core/v1/ReplicationController
core/v1/Secret
core/v1/Service
batch/v1/Job
batch/v1beta1/CronJob
extensions/v1beta1/DaemonSet
extensions/v1beta1/Deployment
extensions/v1beta1/Ingress
extensions/v1beta1/ReplicaSet
apps/v1beta1/StatefulSet
apps/v1beta1/Deployment
)
ADDON_CHECK_INTERVAL_SEC
=
${
TEST_ADDON_CHECK_INTERVAL_SEC
:-
60
}
ADDON_CHECK_INTERVAL_SEC
=
${
TEST_ADDON_CHECK_INTERVAL_SEC
:-
60
}
ADDON_PATH
=
${
ADDON_PATH
:-
/etc/kubernetes/addons
}
ADDON_PATH
=
${
ADDON_PATH
:-
/etc/kubernetes/addons
}
...
@@ -82,6 +105,25 @@ function log() {
...
@@ -82,6 +105,25 @@ function log() {
esac
esac
}
}
# Generate kubectl prune-whitelist flags from provided resource list.
function
generate_prune_whitelist_flags
()
{
local
-r
resources
=(
$@
)
for
resource
in
"
${
resources
[@]
}
"
;
do
printf
"%s"
"--prune-whitelist
${
resource
}
"
done
}
# KUBECTL_EXTRA_PRUNE_WHITELIST is a list of extra whitelisted resources
# besides the default ones.
extra_prune_whitelist
=
if
[
-n
"
${
KUBECTL_EXTRA_PRUNE_WHITELIST
:-}
"
]
;
then
extra_prune_whitelist
=(
${
KUBECTL_EXTRA_PRUNE_WHITELIST
:-}
)
fi
prune_whitelist
=(
${
KUBECTL_PRUNE_WHITELIST
[@]
}
${
extra_prune_whitelist
[@]
}
)
prune_whitelist_flags
=
$(
generate_prune_whitelist_flags
${
prune_whitelist
[@]
})
log INFO
"== Generated kubectl prune whitelist flags:
$prune_whitelist_flags
=="
# $1 filename of addon to start.
# $1 filename of addon to start.
# $2 count of tries to start the addon.
# $2 count of tries to start the addon.
# $3 delay in seconds between two consecutive tries
# $3 delay in seconds between two consecutive tries
...
@@ -126,12 +168,12 @@ function reconcile_addons() {
...
@@ -126,12 +168,12 @@ function reconcile_addons() {
log INFO
"== Reconciling with deprecated label =="
log INFO
"== Reconciling with deprecated label =="
${
KUBECTL
}
${
KUBECTL_OPTS
}
apply
-f
${
ADDON_PATH
}
\
${
KUBECTL
}
${
KUBECTL_OPTS
}
apply
-f
${
ADDON_PATH
}
\
-l
${
CLUSTER_SERVICE_LABEL
}
=
true
,
${
ADDON_MANAGER_LABEL
}
!=
EnsureExists
\
-l
${
CLUSTER_SERVICE_LABEL
}
=
true
,
${
ADDON_MANAGER_LABEL
}
!=
EnsureExists
\
--prune
=
true
--recursive
|
grep
-v
configured
--prune
=
true
${
prune_whitelist_flags
}
--recursive
|
grep
-v
configured
log INFO
"== Reconciling with addon-manager label =="
log INFO
"== Reconciling with addon-manager label =="
${
KUBECTL
}
${
KUBECTL_OPTS
}
apply
-f
${
ADDON_PATH
}
\
${
KUBECTL
}
${
KUBECTL_OPTS
}
apply
-f
${
ADDON_PATH
}
\
-l
${
CLUSTER_SERVICE_LABEL
}
!=
true
,
${
ADDON_MANAGER_LABEL
}
=
Reconcile
\
-l
${
CLUSTER_SERVICE_LABEL
}
!=
true
,
${
ADDON_MANAGER_LABEL
}
=
Reconcile
\
--prune
=
true
--recursive
|
grep
-v
configured
--prune
=
true
${
prune_whitelist_flags
}
--recursive
|
grep
-v
configured
log INFO
"== Kubernetes addon reconcile completed at
$(
date
-Is
)
=="
log INFO
"== Kubernetes addon reconcile completed at
$(
date
-Is
)
=="
}
}
...
...
cluster/gce/gci/configure-helper.sh
View file @
6a880b25
...
@@ -2506,7 +2506,9 @@ EOF
...
@@ -2506,7 +2506,9 @@ EOF
fi
fi
# Place addon manager pod manifest.
# Place addon manager pod manifest.
cp
"
${
src_dir
}
/kube-addon-manager.yaml"
/etc/kubernetes/manifests
src_file
=
"
${
src_dir
}
/kube-addon-manager.yaml"
sed
-i
-e
"s@{{kubectl_extra_prune_whitelist}}@
${
ADDON_MANAGER_PRUNE_WHITELIST
:-}
@g"
"
${
src_file
}
"
cp
"
${
src_file
}
"
/etc/kubernetes/manifests
}
}
# Starts an image-puller - used in test clusters.
# Starts an image-puller - used in test clusters.
...
...
cluster/gce/manifests/kube-addon-manager.yaml
View file @
6a880b25
...
@@ -30,6 +30,9 @@ spec:
...
@@ -30,6 +30,9 @@ spec:
-
mountPath
:
/var/log
-
mountPath
:
/var/log
name
:
varlog
name
:
varlog
readOnly
:
false
readOnly
:
false
env
:
-
name
:
KUBECTL_EXTRA_PRUNE_WHITELIST
value
:
{{
kubectl_extra_prune_whitelist
}}
volumes
:
volumes
:
-
hostPath
:
-
hostPath
:
path
:
/etc/kubernetes/
path
:
/etc/kubernetes/
...
...
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