We use elasticsearch / kibana instead of gcp to register (depending on what is described here ).
To start fluentd-elsticsearch pod, we have established LOGGING_DESTINATION=elasticsearchand ENABLE_NODE_LOGGING="true"to "Template computing instance" → "Custom Metadata" → "kube-env".
While this works fine when done manually, it is overwritten with each gcloud container clusters upgradeone when a new instance template is created with default values ( LOGGING_DESTINATION=gcp...).
My question is: how do I save this configuration for GKE / GCE?
I was thinking of adding k8s-user-startup-script, but which is also defined in the instance template and therefore is overwritten gcloud container clusters upgrade. I also tried adding k8s-user-startup-script to the project metadata, but that doesn't count.
// EDIT
The current workaround (without recreating the instance template and instances) for manually switching to elastics search:
for node in $(kubectl get nodes -o name | cut -f2 -d/); do
gcloud compute ssh $node \
--command="sudo cp -a /srv/salt/fluentd-es/fluentd-es.yaml /etc/kubernetes/manifests/; sudo rm /etc/kubernetes/manifests/fluentd-gcp.yaml";
done
kubelet will pick it up, kill fluentd-gcp and start fluentd-es.
// EDIT # 2 Now run the "DauponSet" "startup-script" for this:
kind: DaemonSet
apiVersion: extensions/v1beta1
metadata:
name: startup-script
namespace: kube-system
labels:
app: startup-script
spec:
template:
metadata:
labels:
app: startup-script
spec:
hostPID: true
containers:
- name: startup-script
image: gcr.io/google-containers/startup-script:v1
securityContext:
privileged: true
env:
- name: STARTUP_SCRIPT
value: |
set -o errexit
set -o pipefail
set -o nounset
if [[ ! -f /etc/kubernetes/manifests/fluentd-es.yaml ]]; then
if [[ -f /home/kubernetes/kube-manifests/kubernetes/fluentd-es.yaml ]]; then
cp -a /home/kubernetes/kube-manifests/kubernetes/fluentd-es.yaml /etc/kubernetes/manifests/
elif [[ -f /srv/salt/fluentd-es/fluentd-es.yaml ]]; then
cp -a /srv/salt/fluentd-es/fluentd-es.yaml /etc/kubernetes/manifests/
fi
test -f /etc/kubernetes/manifests/fluentd-es.yaml && rm /etc/kubernetes/manifests/fluentd-gcp.yaml
fi
jayme source
share