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
13ba1776
Commit
13ba1776
authored
Jun 02, 2015
by
Marek Biskup
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kube-addon-update.sh
parent
51ffa203
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
114 additions
and
32 deletions
+114
-32
README.md
cluster/addons/README.md
+45
-0
influxdb-service.yaml
.../addons/cluster-monitoring/influxdb/influxdb-service.yaml
+2
-0
init.sls
cluster/saltbase/salt/kube-addons/init.sls
+30
-0
initd
cluster/saltbase/salt/kube-addons/initd
+1
-6
kube-addon-update.sh
cluster/saltbase/salt/kube-addons/kube-addon-update.sh
+0
-0
kube-addons.sh
cluster/saltbase/salt/kube-addons/kube-addons.sh
+10
-18
init.sls
cluster/saltbase/salt/kube-master-addons/init.sls
+8
-0
initd
cluster/saltbase/salt/kube-master-addons/initd
+1
-6
kube-master-addons.sh
...er/saltbase/salt/kube-master-addons/kube-master-addons.sh
+2
-0
init.sls
cluster/saltbase/salt/logrotate/init.sls
+1
-1
init.sls
cluster/saltbase/salt/monit/init.sls
+8
-0
kube-addons
cluster/saltbase/salt/monit/kube-addons
+5
-0
monitoring.go
test/e2e/monitoring.go
+1
-1
No files found.
cluster/addons/README.md
0 → 100644
View file @
13ba1776
# Cluster add-ons
Cluster add-ons are Services and Replication Controllers (with pods) that are
shipped with the kubernetes binaries and whose update policy is also consistent
with the update of kubernetes cluster.
On the clusterm the addons are kept in
```/etc/kubernetes/addons```
on the master node, in yaml files
(json is not supported at the moment).
Each add-on must specify the following label:
````kubernetes.io/cluster-service: true````
.
Yaml files that do not define this label will be ignored.
The naming convention for Replication Controllers is
```
<basename>-<version>```, where ```<basename>``` is the same in consecutive
versions and ```<version>``` changes when the component is updated
(```<version>``` must not contain ```-```). For instance,
```
heapseter-controller-v1
``` and ```
heapster-controller-12
``` are the
same controllers with two different versions, while ```
heapseter-controller-v1
```
and ```
heapster-newcontroller-12
``` are treated as two different applications.
For services it is just ```
<basename>
``` (with empty version number)
because we do not expect the service
name to change in consecutive versions. The naming convetion is important for add-on update.
# Add-on update
To update add-ons, just update the contents of ```
/etc/kubernetes/addons
```
directory with the desired definition of add-ons. Then the system will take care
of:
1.
Removing the objects from the API server whose manifest was removed.
1.
This is done for add-ons in the system that do not have a manifest file with the
same basename
1.
Creating objects from new manifests
1.
This is done for manifests that do not correspond to existing API objects
with the same basename
1.
Updating objects whose basename is the samem but whose versions changed.
1.
The update is currently performed by removing the old object and creating
the new one. In the future, rolling update of replication controllers will
be implemented to keep the add-on services up and running during update of add-on
pods.
1.
Note that this cannot happen for Services as their version is always empty.
[

]()
cluster/addons/cluster-monitoring/influxdb/influxdb-service.yaml
View file @
13ba1776
...
...
@@ -5,6 +5,8 @@ metadata:
namespace
:
default
labels
:
k8s-app
:
influxGrafana
kubernetes.io/cluster-service
:
"
true"
kubernetes.io/name
:
"
influxGrafana"
spec
:
ports
:
-
name
:
http
...
...
cluster/saltbase/salt/kube-addons/init.sls
View file @
13ba1776
addon-dir-delete:
file.absent:
- name: /etc/kubernetes/addons
addon-dir-create:
file.directory:
- name: /etc/kubernetes/addons
- user: root
- group: root
- mode: 0755
- require:
- file: addon-dir-delete
{% if pillar.get('enable_cluster_monitoring', '').lower() == 'influxdb' %}
/etc/kubernetes/addons/cluster-monitoring/influxdb:
file.recurse:
...
...
@@ -58,6 +71,13 @@
- group: root
- mode: 755
/etc/kubernetes/kube-addon-update.sh:
file.managed:
- source: salt://kube-addons/kube-addon-update.sh
- user: root
- group: root
- mode: 755
{% if grains['os_family'] == 'RedHat' %}
/usr/lib/systemd/system/kube-addons.service:
...
...
@@ -77,6 +97,16 @@
{% endif %}
# Stop kube-addons service each time salt is executed, just in case
# there was a modification of addons.
# Actually, this should be handled by watching file changes, but
# somehow it doesn't work.
service-kube-addon-stop:
service.dead:
- name: kube-addons
kube-addons:
service.running:
- enable: True
- require:
- service: service-kube-addon-stop
cluster/saltbase/salt/kube-addons/initd
View file @
13ba1776
...
...
@@ -67,12 +67,7 @@ case "$1" in
esac
;;
status
)
if
[
!
-e
${
PIDFILE
}
]
;
then
exit
1
fi
pid
=
$(
cat
${
PIDFILE
})
# Checks that ${pid} is running AND is us.
ps
--no-headers
${
pid
}
|
grep
${
SCRIPTNAME
}
>
/dev/null
||
exit
$?
status_of_proc
-p
$PIDFILE
$KUBE_ADDONS_SH
$NAME
;;
restart|force-reload
)
...
...
cluster/saltbase/salt/kube-addons/kube-addon-update.sh
0 → 100755
View file @
13ba1776
This diff is collapsed.
Click to expand it.
cluster/saltbase/salt/kube-addons/kube-addons.sh
View file @
13ba1776
...
...
@@ -81,7 +81,7 @@ function create-resource-from-string() {
local
-r
config_string
=
$1
;
local
tries
=
$2
;
local
-r
delay
=
$3
;
local
-r
config_name
=
$
1
;
local
-r
config_name
=
$
4
;
while
[
${
tries
}
-gt
0
]
;
do
echo
"
${
config_string
}
"
|
${
KUBECTL
}
create
-f
-
&&
\
echo
"== Successfully started
${
config_name
}
at
$(
date
-Is
)
"
&&
\
...
...
@@ -104,6 +104,7 @@ echo "== Kubernetes addon manager started at $(date -Is) =="
# at the same time as the services that use them.
# NOTE: needs to run as root to read this file.
# Read each line in the csv file of tokens.
# Expect errors when the script is started again.
while
read
line
;
do
# Split each line into the token and username.
IFS
=
','
read
-a
parts
<<<
"
${
line
}
"
...
...
@@ -120,22 +121,13 @@ for obj in $(find /etc/kubernetes/admission-controls \( -name \*.yaml -o -name \
echo
"++ obj
${
obj
}
is created ++"
done
for
obj
in
$(
find /etc/kubernetes/addons
\(
-name
\*
.yaml
-o
-name
\*
.json
\)
)
;
do
start_addon
${
obj
}
100 10 &
echo
"++ addon
${
obj
}
starting in pid
$!
++"
done
noerrors
=
"true"
for
pid
in
$(
jobs
-p
)
;
do
wait
${
pid
}
||
noerrors
=
"false"
echo
"++ pid
${
pid
}
complete ++"
# Check if the configuration has changed recently - in case the user
# created/updated/deleted the files on the master.
while
true
;
do
#kube-addon-update.sh must be deployed in the same directory as this file
`
dirname
$0
`
/kube-addon-update.sh /etc/kubernetes/addons
sleep
600
done
if
[
${
noerrors
}
==
"true"
]
;
then
echo
"== Kubernetes addon manager completed successfully at
$(
date
-Is
)
=="
else
echo
"== Kubernetes addon manager completed with errors at
$(
date
-Is
)
=="
fi
# We stay around so that status checks by salt make it look like
# the service is good. (We could do this is other ways, but this
# is simple.)
sleep
infinity
cluster/saltbase/salt/kube-master-addons/init.sls
View file @
13ba1776
...
...
@@ -25,6 +25,14 @@
{% endif %}
# Used to restart kube-master-addons service each time salt is run
# Actually, it doens't work (the service is not restarted),
# but master-addon service always terminates after it does it job,
# so it is (usually) not running and it will be started when
# salt is run.
# This salt state is not removed because there is a risk
# of introducing regression in 1.0. Please remove it afterwards.
# See also the salt config for kube-addons to see how to restart
# a service on demand.
master-docker-image-tags:
file.touch:
- name: /srv/pillar/docker-images.sls
...
...
cluster/saltbase/salt/kube-master-addons/initd
View file @
13ba1776
...
...
@@ -67,12 +67,7 @@ case "$1" in
esac
;;
status
)
if
[
!
-e
${
PIDFILE
}
]
;
then
exit
1
fi
pid
=
$(
cat
${
PIDFILE
})
# Checks that ${pid} is running AND is us.
ps
--no-headers
${
pid
}
|
grep
${
SCRIPTNAME
}
>
/dev/null
||
exit
$?
status_of_proc
-p
$PIDFILE
$KUBE_MASTER_ADDONS_SH
$NAME
;;
restart|force-reload
)
...
...
cluster/saltbase/salt/kube-master-addons/kube-master-addons.sh
View file @
13ba1776
...
...
@@ -38,3 +38,5 @@ while true; do
done
;
# Now exit. After kube-push, salt will notice that the service is down and it
# will start it and new docker images will be loaded.
cluster/saltbase/salt/logrotate/init.sls
View file @
13ba1776
...
...
@@ -2,7 +2,7 @@ logrotate:
pkg:
- installed
{% set logrotate_files = ['kube-scheduler', 'kube-proxy', 'kubelet', 'kube-apiserver', 'kube-controller-manager'] %}
{% set logrotate_files = ['kube-scheduler', 'kube-proxy', 'kubelet', 'kube-apiserver', 'kube-controller-manager'
, 'kube-addons'
] %}
{% for file in logrotate_files %}
/etc/logrotate.d/{{ file }}:
file:
...
...
cluster/saltbase/salt/monit/init.sls
View file @
13ba1776
...
...
@@ -30,6 +30,14 @@ monit:
- mode: 644
{% endif %}
/etc/monit/conf.d/kube-addons:
file:
- managed
- source: salt://monit/kube-addons
- user: root
- group: root
- mode: 644
/etc/monit/monit_watcher.sh:
file.managed:
- source: salt://monit/monit_watcher.sh
...
...
cluster/saltbase/salt/monit/kube-addons
0 → 100644
View file @
13ba1776
check process kube-addons with pidfile /var/run/kube-addons.pid
group kube-addons
start program = "/etc/init.d/kube-addons start"
stop program = "/etc/init.d/kube-addons stop"
if does not exist then restart
test/e2e/monitoring.go
View file @
13ba1776
...
...
@@ -86,7 +86,7 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error
return
nil
,
err
}
if
len
(
rcList
.
Items
)
!=
1
{
return
nil
,
fmt
.
Errorf
(
"expected to find one replica
t
for RC with label %s but got %d"
,
return
nil
,
fmt
.
Errorf
(
"expected to find one replica for RC with label %s but got %d"
,
rcLabel
,
len
(
rcList
.
Items
))
}
for
_
,
rc
:=
range
rcList
.
Items
{
...
...
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