Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // BackupETCDService defines the template of backup-etcd service for systemd. BackupETCDService = template.Must(template.New("backup-etcd.service").Parse( dedent.Dedent(`[Unit] Description=Backup ETCD [Service] Type=oneshot ExecStart={{ .ScriptPath }} `))) // BackupETCDTimer defines the template of backup-etcd timer for systemd. BackupETCDTimer = template.Must(template.New("backup-etcd.timer").Parse( dedent.Dedent(`[Unit] Description=Timer to backup ETCD [Timer] {{- if .OnCalendarStr }} OnCalendar={{ .OnCalendarStr }} {{- else }} OnCalendar=*-*-* 02:00:00 {{- end }} Unit=backup-etcd.service [Install] WantedBy=multi-user.target `))) )
View Source
var ( // ETCDService defines the template of etcd's service for systemd. ETCDService = template.Must(template.New("etcd.service").Parse( dedent.Dedent(`[Unit] Description=etcd After=network.target [Service] User=root Type=notify EnvironmentFile=/etc/etcd.env ExecStart=/usr/local/bin/etcd NotifyAccess=all RestartSec=10s LimitNOFILE=40000 Restart=always [Install] WantedBy=multi-user.target `))) )
View Source
var EtcdBackupScript = template.Must(template.New("etcd-backup.sh").Parse( dedent.Dedent(`#!/bin/bash set -o errexit set -o nounset set -o pipefail ETCDCTL_PATH='/usr/local/bin/etcdctl' ENDPOINTS='{{ .Etcdendpoint }}' ETCD_DATA_DIR="/var/lib/etcd" BACKUP_DIR="{{ .Backupdir }}/etcd-$(date +%Y-%m-%d-%H-%M-%S)" KEEPBACKUPNUMBER='{{ .KeepbackupNumber }}' ETCDBACKUPSCIPT='{{ .EtcdBackupScriptDir }}' ETCDCTL_CERT="/etc/ssl/etcd/ssl/admin-{{ .Hostname }}.pem" ETCDCTL_KEY="/etc/ssl/etcd/ssl/admin-{{ .Hostname }}-key.pem" ETCDCTL_CA_FILE="/etc/ssl/etcd/ssl/ca.pem" [ ! -d $BACKUP_DIR ] && mkdir -p $BACKUP_DIR export ETCDCTL_API=2;$ETCDCTL_PATH backup --data-dir $ETCD_DATA_DIR --backup-dir $BACKUP_DIR sleep 3 { export ETCDCTL_API=3;$ETCDCTL_PATH --endpoints="$ENDPOINTS" snapshot save $BACKUP_DIR/snapshot.db \ --cacert="$ETCDCTL_CA_FILE" \ --cert="$ETCDCTL_CERT" \ --key="$ETCDCTL_KEY" } > /dev/null sleep 3 cd $BACKUP_DIR/../ && ls -lt |awk '{if(NR > '$KEEPBACKUPNUMBER'){print "rm -rf "$9}}'|sh `)))
EtcdBackupScriptTmpl defines the template of etcd backup script.
View Source
var EtcdEnv = template.Must(template.New("etcd.env").Parse( dedent.Dedent(`# Environment file for etcd {{ .Tag }} ETCD_DATA_DIR=/var/lib/etcd ETCD_ADVERTISE_CLIENT_URLS=https://{{ .Ip }}:2379 ETCD_INITIAL_ADVERTISE_PEER_URLS=https://{{ .Ip }}:2380 ETCD_INITIAL_CLUSTER_STATE={{ .State }} ETCD_METRICS=basic ETCD_LISTEN_CLIENT_URLS=https://{{ .Ip }}:2379,https://127.0.0.1:2379 ETCD_ELECTION_TIMEOUT=5000 ETCD_HEARTBEAT_INTERVAL=250 ETCD_INITIAL_CLUSTER_TOKEN=k8s_etcd ETCD_LISTEN_PEER_URLS=https://{{ .Ip }}:2380 ETCD_NAME={{ .Name }} ETCD_PROXY=off ETCD_ENABLE_V2=true ETCD_INITIAL_CLUSTER={{ .peerAddresses }} ETCD_AUTO_COMPACTION_RETENTION=8 ETCD_SNAPSHOT_COUNT=10000 {{- if .UnsupportedArch }} ETCD_UNSUPPORTED_ARCH={{ .Arch }} {{ end }} # TLS settings ETCD_TRUSTED_CA_FILE=/etc/ssl/etcd/ssl/ca.pem ETCD_CERT_FILE=/etc/ssl/etcd/ssl/member-{{ .Hostname }}.pem ETCD_KEY_FILE=/etc/ssl/etcd/ssl/member-{{ .Hostname }}-key.pem ETCD_CLIENT_CERT_AUTH=true ETCD_PEER_TRUSTED_CA_FILE=/etc/ssl/etcd/ssl/ca.pem ETCD_PEER_CERT_FILE=/etc/ssl/etcd/ssl/member-{{ .Hostname }}.pem ETCD_PEER_KEY_FILE=/etc/ssl/etcd/ssl/member-{{ .Hostname }}-key.pem ETCD_PEER_CLIENT_CERT_AUTH=True # CLI settings ETCDCTL_ENDPOINTS=https://127.0.0.1:2379 ETCDCTL_CA_FILE=/etc/ssl/etcd/ssl/ca.pem ETCDCTL_KEY_FILE=/etc/ssl/etcd/ssl/admin-{{ .Hostname }}-key.pem ETCDCTL_CERT_FILE=/etc/ssl/etcd/ssl/admin-{{ .Hostname }}.pem `)))
EtcdEnv defines the template of etcd's env.
Functions ¶
func BackupTimeOnCalendar ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.