├── LICENSE ├── README.md ├── bin ├── k8s_backup.sh ├── k8s_dump_files.sh ├── k8s_dump_logs.sh ├── k8s_restore.sh └── logger.sh ├── conf ├── kca.conf ├── kca_alertmanager.conf ├── kca_exporter.conf ├── kca_ingress.conf ├── kca_metrics.conf ├── kca_misc.conf ├── kca_prometheus.conf ├── kcc.conf ├── kcc_kibana.conf ├── kcc_misc.conf ├── kcc_orchestration.conf ├── kcc_prometheus.conf ├── kube-system.conf └── sample.conf └── doc ├── Kubernetes集群备份日志文件指南.pdf └── Kubernetes集群资源数据的备份、恢复和自动化.pdf /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # k8s-backup-restore 2 | A utility of backup and restore of Kubernetes config yaml from live cluster. 3 | 4 | ## 1 Download source code from github.com source code repository 5 | ``` 6 | mkdir -p /data 7 | cd /data 8 | git clone https://github.com/solomonxu/k8s-backup-restore.git 9 | ``` 10 | 11 | ## 2 Backup resources from K8s cluster 12 | ``` 13 | cd /data/k8s-backup-restore 14 | ./bin/k8s_backup.sh 15 | ``` 16 | 17 | ## 3 Prepare yaml file with resources of K8s cluster 18 | ``` 19 | cd /data/k8s-backup-restore/data/restore 20 | vi xxx.yaml 21 | ``` 22 | 23 | ## 4 Restore resources into K8s cluster 24 | ``` 25 | ls -n /data/k8s-backup-restore/data/restore 26 | ... 27 | cd /data/k8s-backup-restore 28 | ./bin/k8s_backup.sh 29 | ``` -------------------------------------------------------------------------------- /bin/k8s_backup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | ## show usage 4 | echo "usage: $0 [namespace]" 5 | 6 | ## define variable 7 | BACKUP_PATH=/data/k8s-backup-restore 8 | BACKUP_PATH_BIN=${BACKUP_PATH}/bin 9 | BACKUP_PATH_DATA=${BACKUP_PATH}/data/backup/$(date +%Y%m%d_%H%M%S) 10 | 11 | ## define variable 12 | LOG_PATH=${BACKUP_PATH}/logs 13 | LOG_OUTPUT_FILE_DEFAULT="${LOG_PATH}/backup.log" 14 | 15 | ## Include shells 16 | . ${BACKUP_PATH}/bin/logger.sh 17 | 18 | ## set K8s type 19 | _config_type_list=$(kubectl api-resources | grep -v "events" | awk '{print $1}' | sort) 20 | 21 | ## make dir 22 | mkdir -p ${BACKUP_PATH_BIN} 23 | mkdir -p ${BACKUP_PATH_DATA} 24 | mkdir -p ${LOG_PATH} 25 | cd ${BACKUP_PATH_DATA} 26 | 27 | ## set namespace list 28 | _ns_list=$(kubectl get ns | awk '{print $1}' | grep -v NAME) 29 | if [ $# -ge 1 ]; then 30 | _ns_list="$@" 31 | fi 32 | 33 | ## define counters 34 | _count0=0 35 | _count1=0 36 | _count2=0 37 | _count3=0 38 | 39 | ## print hint 40 | logger_info "Backup kubernetes config in [namespaces: ${_ns_list}] now." 41 | logger_info "Backup kubernetes config for [type: ${_config_type_list}]." 42 | logger_info "If you want to read the record of backup, please input command ' tail -100f ${LOG_OUTPUT_FILE_DEFAULT} '" 43 | 44 | ## ask and answer 45 | logger_info "This will backup resources of kubernetes cluster to yaml files." 46 | read -n 1 -p "Do you want to continue? [yes/no] " input_char && printf "\n" 47 | if [ "${input_char}" != 'y' ]; then 48 | logger_info "Exit by user's selection." 49 | exit 1 50 | fi 51 | 52 | ## loop for namespaces 53 | for _ns in ${_ns_list}; do 54 | _count0=$[_count0 + 1] 55 | logger_info "Backup No.${_count0} namespace [namespace: ${_ns}]." 56 | _count2=0 57 | ## loop for types 58 | for _type in ${_config_type_list}; do 59 | logger_info "Backup type [namespace: ${_ns}, type: ${_type}]." 60 | _item_list=$(kubectl -n ${_ns} get ${_type} | grep -v NAME | awk '{print $1}' ) 61 | _count1=0 62 | ## loop for items 63 | for _item in ${_item_list}; do 64 | _file_name=${BACKUP_PATH_DATA}/${_ns}_${_type}_${_item}.yaml 65 | logger_info "Backup kubernetes config yaml [namespace: ${_ns}, type: ${_type}, item: ${_item}] to file: ${_file_name}" 66 | kubectl -n ${_ns} get ${_type} ${_item} -o yaml > ${_file_name} 67 | _count1=$[_count1 + 1] 68 | _count2=$[_count2 + 1] 69 | _count3=$[_count3 + 1] 70 | logger_info "Backup No.${_count3} file done." 71 | done; 72 | done; 73 | logger_info "Backup ${_count2} files done in [namespace: ${_ns}]." 74 | done; 75 | 76 | ## show stats 77 | logger_info "Backup ${_count3} yaml files in all." 78 | logger_info "kubernetes Backup completed, all done." 79 | exit 0 80 | -------------------------------------------------------------------------------- /bin/k8s_dump_files.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | ## show usage 4 | echo "usage: $0 [configfile]" 5 | echo " configfile: the default config file is podfile.conf" 6 | 7 | ## define constants 8 | CMD_LIST="ps.-ef ps.-efL lsof.-a" 9 | 10 | ## define variable 11 | BACKUP_PATH=/data/k8s-backup-restore 12 | BACKUP_PATH_BIN=${BACKUP_PATH}/bin 13 | BACKUP_PATH_PODFILE=${BACKUP_PATH}/data/podfile 14 | SUB_PATH=$(date +%Y%m%d_%H%M%S) 15 | BACKUP_PATH_DATA=${BACKUP_PATH_PODFILE}/${SUB_PATH} 16 | 17 | ## define variable 18 | LOG_PATH=${BACKUP_PATH}/logs 19 | LOG_OUTPUT_FILE_DEFAULT="${LOG_PATH}/backup.log" 20 | 21 | ## Include shells 22 | . ${BACKUP_PATH}/bin/logger.sh 23 | 24 | ## Initialize 25 | function init() 26 | { 27 | ## make dir 28 | mkdir -p ${BACKUP_PATH_BIN} 29 | mkdir -p ${BACKUP_PATH_DATA} 30 | mkdir -p ${LOG_PATH} 31 | cd ${BACKUP_PATH_DATA} 32 | 33 | ## set config file 34 | _config_file=${BACKUP_PATH}/conf/podfile.conf 35 | if [ $# -ge 1 ]; then 36 | _config_file=${BACKUP_PATH}/conf/$1 37 | fi 38 | ## check pod config file 39 | if [ ! -f "${_config_file}" ]; then 40 | logger_error "Pod config ${_config_file} not existed, exit." 41 | exit 1; 42 | fi 43 | ## read pod config file 44 | _podfile_list=$(cat ${_config_file} | grep -v "##" | awk 'BEGIN{OFS="#"}{if($0!=""){print $1,$2,$3,$4}}') 45 | logger_info "_podfile_list=${_podfile_list}" 46 | } 47 | 48 | ## Dump container's files 49 | function dump_container_files() 50 | { 51 | _namespace_prior="" 52 | ## define counters 53 | _count=0 54 | ## loop for podfile list 55 | for _podfile_line in ${_podfile_list}; do 56 | ## check podfile line 57 | if [ -z "${_podfile_line}" ]; then 58 | continue; 59 | fi 60 | logger_info "_podfile_line="${_podfile_line} 61 | _namespace=$( echo ${_podfile_line} | awk -F# '{print $1}') 62 | _pod_prefix=$(echo ${_podfile_line} | awk -F# '{print $2}') 63 | _container=$( echo ${_podfile_line} | awk -F# '{print $3}') 64 | _file_list=$( echo ${_podfile_line} | awk -F# '{print $4}' | awk -F: '{for(i=1;i<=NF;i++) print $i}') 65 | logger_info "Config line: _namespace=${_namespace}, _pod_prefix=${_pod_prefix}, _container=${_container}, _file_list=${_file_list}" 66 | ## check pod argument 67 | if [ -z "${_pod_prefix}" ]; then 68 | continue; 69 | fi 70 | ## set to prior namespace 71 | if [ -z "${_namespace}" ]; then 72 | _namespace=${_namespace_prior} 73 | fi 74 | _namespace_prior=${_namespace} 75 | ## set namespace argument 76 | _ns_arg="--all-namespaces" 77 | if [ -n "${_namespace}" ]; then 78 | _ns_arg="-n ${_namespace}" 79 | fi 80 | ## set container argument 81 | _container_arg="" 82 | _container_suffix="default" 83 | if [ "${_container}" != "-" ]; then 84 | _container_arg="-c ${_container}" 85 | _container_suffix=${_container} 86 | fi 87 | ## get pod list 88 | _pod_list=$(kubectl get pods ${_ns_arg} | grep -v "NAME" | grep "${_pod_prefix}-" | awk '{print $1}') 89 | for _pod in ${_pod_list}; do 90 | _pod_root="${BACKUP_PATH_DATA}/${_namespace}_pod_${_pod}_${_container_suffix}" 91 | mkdir -p ${_pod_root} 92 | 93 | ## Describe pod 94 | _descfile="${_pod_root}/pod_desc.txt" 95 | logger_info "Describe pod ${_pod} to file: ${_descfile}." 96 | _ret_val=$(kubectl ${_ns_arg} describe pod ${_pod} > ${_descfile}) 97 | logger_info "Describe pod ${_pod} ok." 98 | 99 | ## Loop for command list 100 | for _cmd in ${CMD_LIST}; do 101 | _cmd=${_cmd//./ } 102 | _cmd_output="${_pod_root}/cmd_output_${_container_suffix}.txt" 103 | ## Execute command from container to local host 104 | logger_info "Execute command '${_cmd}' at pod ${_pod} container ${_container}, output to file: ${_cmd_output}." 105 | _ret_val=$(echo "# $(date '+%Y-%m-%d %H:%M:%S') Execute command: ${_cmd}" >> ${_cmd_output}) 106 | _ret_val=$(kubectl ${_ns_arg} exec -it ${_pod} ${_container_arg} -- ${_cmd} >> ${_cmd_output}) 107 | logger_info "Execute command ok." 108 | done 109 | 110 | ## Dump container log 111 | _logfile="${_pod_root}/container_${_container_suffix}.log" 112 | logger_info "Dump pod ${_pod} container ${_container_suffix} log to file: ${_logfile}." 113 | _ret_val=$(kubectl ${_ns_arg} logs ${_pod} ${_container_arg} > ${_logfile}) 114 | logger_info "Dump pod ${_pod} log file ok." 115 | 116 | ## Loop for file list 117 | for _file in ${_file_list}; do 118 | _local_file="${_pod_root}${_file}" 119 | _local_dir="${_pod_root}${_file%/*}" 120 | mkdir -p ${_local_dir} 121 | ## Dump file/dir from container to local host 122 | logger_info "Dump pod ${_pod} container ${_container} file ${_file} to local host: ${_local_file}." 123 | _ret_val=$(kubectl ${_ns_arg} cp ${_pod}:${_file} ${_container_arg} ${_local_file}) 124 | logger_info "Dump pod ${_pod} file ok." 125 | _count=$[_count+1] 126 | done 127 | done 128 | done; 129 | logger_info "Dump ${_count} files/dirs done." 130 | } 131 | 132 | ## Package files into zip 133 | function package_zip() 134 | { 135 | ## Package container files to a zip file 136 | _config_affix=$( echo ${_config_file} | awk -F/ '{print $NF}' | awk -F. '{print $1}') 137 | _zip_file="${BACKUP_PATH_PODFILE}/podfiles_${_config_affix}_${SUB_PATH}.tar" 138 | logger_info "Package container files into zip file..." 139 | cd ${BACKUP_PATH_PODFILE} 140 | tar -cvPf ${_zip_file} ${SUB_PATH} 141 | gzip ${_zip_file} 142 | logger_info "Package container files into zip file: ${_zip_file}.gz done." 143 | } 144 | 145 | ## Initialize 146 | init $@; 147 | 148 | ## Dump container's files 149 | dump_container_files; 150 | 151 | ## Package files into zip 152 | package_zip; 153 | -------------------------------------------------------------------------------- /bin/k8s_dump_logs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | ## show usage 4 | echo "usage: $0 [namespace]" 5 | echo " namespace: the default value is wisecloud-controller." 6 | 7 | ## define variable 8 | BACKUP_PATH=/data/k8s-backup-restore 9 | BACKUP_PATH_BIN=${BACKUP_PATH}/bin 10 | BACKUP_PATH_LOGFILE=${BACKUP_PATH}/data/logfile 11 | SUB_PATH=$(date +%Y%m%d_%H%M%S) 12 | BACKUP_PATH_DATA=${BACKUP_PATH_LOGFILE}/${SUB_PATH} 13 | 14 | ## define variable 15 | LOG_PATH=${BACKUP_PATH}/logs 16 | LOG_OUTPUT_FILE_DEFAULT="${LOG_PATH}/backup.log" 17 | 18 | ## Include shells 19 | . ${BACKUP_PATH}/bin/logger.sh 20 | 21 | ## make dir 22 | mkdir -p ${BACKUP_PATH_BIN} 23 | mkdir -p ${BACKUP_PATH_DATA} 24 | mkdir -p ${LOG_PATH} 25 | cd ${BACKUP_PATH_DATA} 26 | 27 | ## set namespace 28 | _ns="wisecloud-controller" 29 | if [ $# -ge 1 ]; then 30 | _ns="$1" 31 | fi 32 | 33 | ## get pod in namespace 34 | _pod_list=$(kubectl -n ${_ns} get pod | grep -v "NAME" | awk '{print $1}' | sort) 35 | 36 | ## define counters 37 | _count=0 38 | ## loop for pod list 39 | for _pod in ${_pod_list}; do 40 | _containers_list=$(kubectl -n ${_ns} describe pod ${_pod} | grep -v " " | awk -F: '{if($1=="Containers"){found="true"} else if(found=="true" && substr($0,0,1)!=" "){exit(0)} else if(found=="true"){print $1}}') 41 | echo _containers_list=${_containers_list} 42 | for _container in ${_containers_list}; do 43 | _logfile=${BACKUP_PATH_DATA}/${_pod}.log 44 | if [ -n ${_container} ]; then 45 | _container_arg="-c ${_container}" 46 | _logfile=${BACKUP_PATH_DATA}/${_pod}_${_container}.log 47 | fi 48 | logger_info "Dump pod ${_pod} container ${_container} log to file: ${_logfile}." 49 | kubectl -n ${_ns} logs ${_pod} ${_container_arg} > ${_logfile} 50 | logger_info "Dump pod ${_pod} log file done." 51 | _count=$[_count+1] 52 | done; 53 | done; 54 | logger_info "Dump ${_count} log files in [namespace: ${_ns}] done." 55 | 56 | ## package log files to a zip file 57 | ZIP_FILE=${BACKUP_PATH_LOGFILE}/log_${_ns}_${SUB_PATH}.tar 58 | logger_info "Package log files into zip file..." 59 | cd ${BACKUP_PATH_LOGFILE} 60 | tar -cvPf ${ZIP_FILE} ${SUB_PATH} 61 | gzip ${ZIP_FILE} 62 | logger_info "Package log files into zip file: ${ZIP_FILE}.gz done." 63 | -------------------------------------------------------------------------------- /bin/k8s_restore.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | ## define constants 4 | BACKUP_PATH=/data/k8s-backup-restore 5 | BACKUP_PATH_BIN=${BACKUP_PATH}/bin 6 | BACKUP_PATH_DATA=${BACKUP_PATH}/data/restore 7 | 8 | ## define constants 9 | LOG_PATH=${BACKUP_PATH}/logs 10 | LOG_OUTPUT_FILE_DEFAULT="${LOG_PATH}/restore.log" 11 | 12 | ## Include shells 13 | . ${BACKUP_PATH}/bin/logger.sh 14 | 15 | ## make dir 16 | mkdir -p ${BACKUP_PATH_BIN} 17 | mkdir -p ${BACKUP_PATH_DATA} 18 | mkdir -p ${LOG_PATH} 19 | cd ${BACKUP_PATH_DATA} 20 | 21 | ## print hint 22 | logger_info "Kubernetes Restore start now. All yaml files which located in path [${BACKUP_PATH_DATA}] will be applied." 23 | logger_info "If you want to read the log record of restore, please input command ' tail -100f ${RESTORE_LOG_FILE} '" 24 | 25 | ## list yaml files 26 | _file_list=$(ls -n ${BACKUP_PATH_DATA}/*.yaml | awk '{print $9}') 27 | _file_count=$(echo ${_file_list} | wc -w) 28 | 29 | ## ask and answer 30 | logger_warn "WARNING!!! This will create ${_file_count} resources from yaml files into kubernetes cluster. While same name of resources will be deleted. Please consider it carefully!" 31 | read -n 1 -p "Do you want to continue? [yes/no/show] " input_char && printf "\n" 32 | if [ "${input_char}" == 's' ]; then 33 | logger_info "Show yaml files list, then exit." 34 | ls -n ${BACKUP_PATH_DATA}/*.yaml 35 | exit 1 36 | elif [ "${input_char}" != 'y' ]; then 37 | logger_info "Exit by user's selection." 38 | exit 2 39 | fi 40 | 41 | ## loop for file list 42 | _count=0 43 | _count_delete_ok=0 44 | _count_create_ok=0 45 | _count_delete_failed=0 46 | _count_create_failed=0 47 | for _file_yaml in ${_file_list}; do 48 | _count=$[_count + 1] 49 | logger_info "Restore No.${_count} resources from yaml file: ${_file_yaml}..." 50 | _cmd_delete="kubectl delete -f ${_file_yaml}" 51 | _cmd_create="kubectl create -f ${_file_yaml}" 52 | 53 | ## run delete 54 | logger_info "Run shell: ${_cmd_delete}." 55 | kubectl delete -f ${_file_yaml} 56 | if [ $? -eq 0 ]; then 57 | _result="ok" 58 | _count_delete_ok=$[_count_delete_ok+1] 59 | else 60 | _result="failed" 61 | _count_delete_failed=$[_count_delete_failed+1] 62 | fi 63 | logger_info "Delete resource from ${_file_yaml}: ${_result}." 64 | 65 | ## run create 66 | logger_info "Run shell: ${_cmd_create}." 67 | kubectl create -f ${_file_yaml} 68 | if [ $? -eq 0 ]; then 69 | _result="ok" 70 | _count_create_ok=$[_count_create_ok+1] 71 | else 72 | _result="failed" 73 | _count_create_failed=$[_count_create_failed+1] 74 | fi 75 | logger_info "Create resource from ${_file_yaml}: ${_result}." 76 | done; 77 | 78 | ## show stats 79 | logger_info "Restore ${_count} resources from yaml files in all: count_delete_ok=${_count_delete_ok}, count_delete_failed=${_count_delete_failed}, count_create_ok=${_count_create_ok}, count_create_failed=${_count_create_failed}." 80 | logger_info "Kubernetes Restore completed, all done." 81 | exit 0; 82 | -------------------------------------------------------------------------------- /bin/logger.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | ## Define constants 4 | LOG_LANG_ALL="zh en fr" 5 | LOG_MSG_TEMPLATE_AFFIX="backup-msg_" 6 | #LOG_PATH="./logs" 7 | #LOG_OUTPUT_FILE_DEFAULT="${LOG_PATH}/backup.log" 8 | 9 | ## Define variables 10 | LOG_DEBUG_LEVEL=0 11 | LOG_OUTPUT_FILE=$LOG_OUTPUT_FILE_DEFAULT 12 | LOG_OUTPUT_CONSOLE=true 13 | LOG_LANG=en 14 | LOG_MSG_TEMPLATE="backup-msg_${LOG_LANG}.tmpl" 15 | TZ="Asia/Shanghai" 16 | 17 | ## Make log path 18 | mkdir -p $LOG_PATH 19 | 20 | ## Set time zone of message 21 | logger_set_timezone() 22 | { 23 | if [ $# -ge 1 ]; then 24 | TZ=$1 25 | logger_info "Set timezone, TZ=${TZ}." 26 | fi 27 | } 28 | 29 | ## Set logfile path to output 30 | logger_set_output() 31 | { 32 | if [ $# -ge 1 ]; then 33 | LOG_OUTPUT_FILE=$1 34 | fi 35 | } 36 | 37 | ## Set language 38 | logger_set_lang() 39 | { 40 | if [ $# -le 0 ]; then 41 | return; 42 | fi 43 | for lang in ${LOG_LANG_ALL}; do 44 | if [ ${lang} = $1 ]; then 45 | LOG_LANG=${lang} 46 | LOG_MSG_TEMPLATE="${LOG_MSG_TEMPLATE_AFFIX}${LOG_LANG}.tmpl" 47 | fi 48 | done 49 | } 50 | 51 | ## Logger output 52 | logger_output_private() 53 | { 54 | if [ $# -le 0 ]; then 55 | return; 56 | fi 57 | info_level=$1 58 | msg_id=$2 59 | shift 60 | millisecond=$(expr $(date +%N) / 1000) 61 | debug_msg_head="$(TZ=$TZ date '+%Y-%m-%d %H:%M:%S').$(printf '%06d' ${millisecond}) [$$] - ${info_level} " 62 | if [ "${msg_id:0:3}" = "MSG" ]; then 63 | shift 64 | pattern=$($msg_id) 65 | debug_msg="${debug_msg_head}""$(printf $pattern $@ )" 66 | else 67 | debug_msg="${debug_msg_head}$@" 68 | fi 69 | #debug_msg=${debug_msg_head}$(printf $2 ) 70 | echo "${debug_msg}" >> ${LOG_OUTPUT_FILE} 71 | if [ ${LOG_OUTPUT_CONSOLE} = true ]; then 72 | echo "${debug_msg}" 73 | fi 74 | } 75 | 76 | ## Logger debug 0 77 | logger_debug() 78 | { 79 | if [ ${LOG_DEBUG_LEVEL} -le 0 ]; then 80 | logger_output_private "DEBUG" $@ 81 | fi 82 | } 83 | 84 | ## Logger info 1 85 | logger_info() 86 | { 87 | if [ ${LOG_DEBUG_LEVEL} -le 1 ]; then 88 | logger_output_private "INFO" $@ 89 | fi 90 | } 91 | 92 | ## Logger warn 2 93 | logger_warn() 94 | { 95 | if [ ${LOG_DEBUG_LEVEL} -le 2 ]; then 96 | logger_output_private "WARN" $@ 97 | fi 98 | } 99 | 100 | ## Logger warn 3 101 | logger_error() 102 | { 103 | if [ ${LOG_DEBUG_LEVEL} -le 3 ]; then 104 | logger_output_private "ERROR" $@ 105 | fi 106 | } 107 | 108 | ## Logger alert 4 109 | logger_alert() 110 | { 111 | if [ ${LOG_DEBUG_LEVEL} -le 4 ]; then 112 | logger_output_private "ALERT" $@ 113 | fi 114 | } 115 | 116 | ## Logger fatal 5 117 | logger_fatal() 118 | { 119 | if [ ${LOG_DEBUG_LEVEL} -le 5 ]; then 120 | logger_output_private "FATAL" $@ 121 | fi 122 | } 123 | -------------------------------------------------------------------------------- /conf/kca.conf: -------------------------------------------------------------------------------- 1 | ## all 2 | ## namespace: wisecloud-agent 3 | 4 | ## namespace pod-prefix container file_or_path 5 | wisecloud-agent alertmanager-main alertmanager /run/secrets/:/etc/alertmanager/:/alertmanager/ 6 | wisecloud-agent alertmanager-main config-reloader /etc/alertmanager/ 7 | wisecloud-agent component-exporter-agent component-exporter-agent /usr/share/apk/:/run/secrets/:/etc/exporter/:/tmp/ 8 | wisecloud-agent confagent confagent /usr/share/apk/:/run/secrets/:/var/run/wiserun/:/etc/crontabs/:/tmp/ 9 | 10 | wisecloud-agent filebeat wise-logger /usr/share/apk/:/run/secrets/:/etc/crontabs/ 11 | wisecloud-agent filebeat wise-logger /tmp/:/host/var/log/:/data/wisecloud/ingress-gateway/:/jsonfile/:/usr/share/filebeat/ 12 | 13 | wisecloud-agent ingress-agent ingress-agent /usr/share/apk/:/run/secrets/:/etc/crontabs/:/etc/kubernetes/ 14 | wisecloud-agent ingress-gateway ingress-gateway /usr/share/apk/:/run/secrets/:/etc/crontabs/:/go/bin/wisecloud-ingress-gateway/ 15 | wisecloud-agent ingress-gateway ingress-gateway /tmp/:/var/log/ingress-gateway/ 16 | 17 | wisecloud-agent k8s-network-exporter k8s-network-exporter /usr/share/apk/:/run/secrets/:/etc/crontabs/ 18 | 19 | wisecloud-agent kube-state-metrics kube-rbac-proxy-main /usr/share/apk/:/run/secrets/:/etc/crontabs/:/tmp/ 20 | wisecloud-agent kube-state-metrics kube-rbac-proxy-self /usr/share/apk/:/run/secrets/:/etc/crontabs/:/tmp/ 21 | ##wisecloud-agent kube-state-metrics kube-state-metrics /tmp/ 22 | wisecloud-agent kube-state-metrics addon-resizer /usr/share/apk/:/run/secrets/:/tmp/ 23 | 24 | wisecloud-agent metadata metadata /usr/share/apk/:/run/secrets/:/etc/crontabs/:/go/bin/wise2c-metadata/conf/:/tmp/ 25 | wisecloud-agent node-exporter node-exporter /run/secrets/:/tmp/ 26 | 27 | wisecloud-agent prometheus-k8s prometheus /run/secrets/:/tmp/:/etc/prometheus/ 28 | ##wisecloud-agent prometheus-k8s prometheus /prometheus/wal/ 29 | ##wisecloud-agent prometheus-k8s prometheus /prometheus/ 30 | wisecloud-agent prometheus-k8s prometheus /run/secrets/:/tmp/ 31 | wisecloud-agent prometheus-k8s prometheus-config-reloader /run/secrets/:/tmp/:/etc/prometheus/ 32 | 33 | wisecloud-agent prometheus-k8s rules-configmap-reloader /tmp/ 34 | wisecloud-agent prometheus-k8s thanos-sidecar /run/secrets/:/tmp/ 35 | ##wisecloud-agent prometheus-k8s thanos-sidecar /prometheus/wal/ 36 | ##wisecloud-agent prometheus-k8s thanos-sidecar /prometheus/ 37 | 38 | wisecloud-agent prometheus-operator prometheus-operator /run/secrets/:/tmp/ 39 | wisecloud-agent prometheus-remote-adapter prometheus-remote-adapter /usr/share/apk/:/run/secrets/:/etc/crontabs/:/tmp/ 40 | wisecloud-agent prometheus-thanos-query thanos-query /run/secrets/:/tmp/ 41 | -------------------------------------------------------------------------------- /conf/kca_alertmanager.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-agent 3 | ## pod-prefix: alertmanager-*** 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-agent alertmanager-main alertmanager /run/secrets/:/etc/alertmanager/:/alertmanager/ 7 | wisecloud-agent alertmanager-main config-reloader /etc/alertmanager/ 8 | -------------------------------------------------------------------------------- /conf/kca_exporter.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-agent 3 | ## pod-prefix: **-exporter 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-agent component-exporter-agent component-exporter-agent /usr/share/apk/:/run/secrets/:/etc/exporter/:/tmp/ 7 | wisecloud-agent k8s-network-exporter k8s-network-exporter /usr/share/apk/:/run/secrets/:/etc/crontabs/ 8 | wisecloud-agent node-exporter node-exporter /run/secrets/:/tmp/ -------------------------------------------------------------------------------- /conf/kca_ingress.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-agent 3 | ## pod-prefix: ingress-*** 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-agent ingress-agent ingress-agent /usr/share/apk/:/run/secrets/:/etc/crontabs/:/etc/kubernetes/ 7 | wisecloud-agent ingress-gateway ingress-gateway /usr/share/apk/:/run/secrets/:/etc/crontabs/:/go/bin/wisecloud-ingress-gateway/ 8 | wisecloud-agent ingress-gateway ingress-gateway /tmp/:/var/log/ingress-gateway/ 9 | -------------------------------------------------------------------------------- /conf/kca_metrics.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-agent 3 | ## pod-prefix: ***-metrics 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-agent kube-state-metrics kube-rbac-proxy-main /usr/share/apk/:/run/secrets/:/etc/crontabs/:/tmp/ 7 | wisecloud-agent kube-state-metrics kube-rbac-proxy-self /usr/share/apk/:/run/secrets/:/etc/crontabs/:/tmp/ 8 | ##wisecloud-agent kube-state-metrics kube-state-metrics /tmp/ 9 | wisecloud-agent kube-state-metrics addon-resizer /usr/share/apk/:/run/secrets/:/tmp/ -------------------------------------------------------------------------------- /conf/kca_misc.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-agent 3 | ## pod-prefix: confagent, filebeat, metadata 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-agent confagent confagent /usr/share/apk/:/run/secrets/:/var/run/wiserun/:/etc/crontabs/:/tmp/ 7 | wisecloud-agent filebeat wise-logger /usr/share/apk/:/run/secrets/:/etc/crontabs/ 8 | wisecloud-agent filebeat wise-logger /tmp/:/host/var/log/:/data/wisecloud/ingress-gateway/:/jsonfile/:/usr/share/filebeat/ 9 | wisecloud-agent metadata metadata /usr/share/apk/:/run/secrets/:/etc/crontabs/:/go/bin/wise2c-metadata/conf/:/tmp/ 10 | -------------------------------------------------------------------------------- /conf/kca_prometheus.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-agent 3 | ## pod-prefix: prometheus-*** 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-agent prometheus-k8s prometheus /run/secrets/:/tmp/:/etc/prometheus/ 7 | ##wisecloud-agent prometheus-k8s prometheus /prometheus/wal/ 8 | ##wisecloud-agent prometheus-k8s prometheus /prometheus/ 9 | wisecloud-agent prometheus-k8s prometheus /run/secrets/:/tmp/ 10 | wisecloud-agent prometheus-k8s prometheus-config-reloader /run/secrets/:/tmp/:/etc/prometheus/ 11 | 12 | wisecloud-agent prometheus-k8s rules-configmap-reloader /tmp/ 13 | wisecloud-agent prometheus-k8s thanos-sidecar /run/secrets/:/tmp/ 14 | ##wisecloud-agent prometheus-k8s thanos-sidecar /prometheus/wal/ 15 | ##wisecloud-agent prometheus-k8s thanos-sidecar /prometheus/ 16 | 17 | wisecloud-agent prometheus-operator prometheus-operator /run/secrets/:/tmp/ 18 | wisecloud-agent prometheus-remote-adapter prometheus-remote-adapter /usr/share/apk/:/run/secrets/:/etc/crontabs/:/tmp/ 19 | wisecloud-agent prometheus-thanos-query thanos-query /run/secrets/:/tmp/ 20 | -------------------------------------------------------------------------------- /conf/kcc.conf: -------------------------------------------------------------------------------- 1 | ## all 2 | ## namespace: wisecloud-controller 3 | 4 | ## namespace pod-prefix container file_or_path 5 | wisecloud-controller artifactory artifactory /usr/share/apk/:/run/secrets/:/root/artifactory-data:/tmp/ 6 | 7 | wisecloud-controller backup-restore backup-restore /usr/share/apk/:/run/secrets/:/go/bin/backup-restore/conf/:/tmp/backup/ 8 | 9 | wisecloud-controller cluster-controller cluster-controller /usr/share/apk/:/run/secrets/:/templates-yamls/:/globalkube.conf.yaml 10 | 11 | wisecloud-controller component-exporter-controller component-exporter-controller /usr/share/apk/:/run/secrets/:/etc/exporter/:/etc/component-exporter-config.yaml 12 | 13 | wisecloud-controller config-center config-center /usr/share/apk/:/run/secrets/ 14 | 15 | wisecloud-controller curator curator /usr/share/apk/:/run/secrets/ 16 | 17 | wisecloud-controller elasticsearch elasticsearch /run/secrets/:/usr/share/elasticsearch/config/:/usr/share/elasticsearch/logs/ 18 | ##wisecloud-controller elasticsearch elasticsearch /usr/share/elasticsearch/ 19 | ##wisecloud-controller elasticsearch elasticsearch /tmp/ 20 | 21 | wisecloud-controller grafana grafana /run/secrets/:/usr/share/grafana/conf/:/usr/share/grafana/scripts/ 22 | ##wisecloud-controller grafana grafana /usr/share/grafana/ 23 | 24 | wisecloud-controller helm helm /usr/share/apk/:/run/secrets/:/wisecloud/ 25 | 26 | wisecloud-controller java-gw java-gw /usr/share/apk/:/run/secrets/:/entrypoint.sh 27 | ##wisecloud-controller java-gw java-gw /tmp/ 28 | 29 | wisecloud-controller kibana kibana /run/secrets/:/usr/share/kibana/conf/:/usr/share/kibana/data/ 30 | ##wisecloud-controller kibana kibana /var/log/:/usr/share/kibana/ 31 | 32 | wisecloud-controller metrics metrics /run/secrets/:/var/log/:/entrypoint.sh 33 | ##wisecloud-controller metrics metrics /tmp/ 34 | 35 | wisecloud-controller monitor-api monitor-api /usr/share/apk/:/run/secrets/:/tmp/ 36 | 37 | wisecloud-controller orchestration ingress-controller /usr/share/apk/:/run/secrets/:/go/bin/ingress-controller/conf/ 38 | wisecloud-controller orchestration toscaapi /usr/share/apk/:/run/secrets/:/usr/src/app/ 39 | wisecloud-controller orchestration translator /usr/share/apk/:/run/secrets/:/app/ 40 | wisecloud-controller orchestration catalog /usr/share/apk/:/run/secrets/ 41 | wisecloud-controller orchestration auto-scaling /usr/share/apk/:/run/secrets/:/conf 42 | 43 | wisecloud-controller prometheus prometheus /var/run/secrets/:/etc/prometheus/ 44 | -------------------------------------------------------------------------------- /conf/kcc_kibana.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-controller 3 | ## pod-prefix: elasticsearch, kibana 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-controller elasticsearch elasticsearch /run/secrets/:/usr/share/elasticsearch/config/:/usr/share/elasticsearch/logs/ 7 | ##wisecloud-controller elasticsearch elasticsearch /usr/share/elasticsearch/ 8 | ##wisecloud-controller elasticsearch elasticsearch /tmp/ 9 | wisecloud-controller kibana kibana /run/secrets/:/usr/share/kibana/conf/:/usr/share/kibana/data/ 10 | ##wisecloud-controller kibana kibana /var/log/:/usr/share/kibana/ 11 | -------------------------------------------------------------------------------- /conf/kcc_misc.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-controller 3 | ## pod-prefix: artifactory, backup-restore, curator, helm. 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-controller artifactory artifactory /usr/share/apk/:/run/secrets/:/root/artifactory-data:/tmp/ 7 | wisecloud-controller backup-restore backup-restore /usr/share/apk/:/run/secrets/:/go/bin/backup-restore/conf/:/tmp/backup/ 8 | wisecloud-controller curator curator /usr/share/apk/:/run/secrets/ 9 | wisecloud-controller helm helm /usr/share/apk/:/run/secrets/:/wisecloud/ 10 | -------------------------------------------------------------------------------- /conf/kcc_orchestration.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-controller 3 | ## pod-prefix: orchestration, java-gw, config-center, cluster-controller. 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-controller java-gw java-gw /usr/share/apk/:/run/secrets/:/entrypoint.sh 7 | wisecloud-controller java-gw java-gw /tmp/ 8 | wisecloud-controller config-center config-center /usr/share/apk/:/run/secrets/ 9 | wisecloud-controller config-center config-center /tmp/ 10 | wisecloud-controller orchestration ingress-controller /usr/share/apk/:/run/secrets/:/go/bin/ingress-controller/conf/ 11 | wisecloud-controller orchestration ingress-controller /tmp/ 12 | wisecloud-controller orchestration toscaapi /usr/share/apk/:/run/secrets/:/usr/src/app/ 13 | wisecloud-controller orchestration toscaapi /tmp/ 14 | wisecloud-controller orchestration translator /usr/share/apk/:/run/secrets/:/app/ 15 | wisecloud-controller orchestration translator /tmp/ 16 | wisecloud-controller orchestration catalog /usr/share/apk/:/run/secrets/ 17 | wisecloud-controller orchestration catalog /tmp/ 18 | wisecloud-controller orchestration auto-scaling /usr/share/apk/:/run/secrets/:/conf/ 19 | wisecloud-controller orchestration auto-scaling /tmp/ 20 | wisecloud-controller cluster-controller cluster-controller /usr/share/apk/:/run/secrets/:/templates-yamls/:/globalkube.conf.yaml 21 | wisecloud-controller cluster-controller cluster-controller /tmp/ 22 | -------------------------------------------------------------------------------- /conf/kcc_prometheus.conf: -------------------------------------------------------------------------------- 1 | ## subset 2 | ## namespace: wisecloud-controller 3 | ## pod-prefix: component-exporter-controller, metrics, prometheus, grafana. 4 | 5 | ## namespace pod-prefix container file_or_path 6 | wisecloud-controller component-exporter-controller component-exporter-controller /usr/share/apk/:/run/secrets/:/etc/exporter/:/etc/component-exporter-config.yaml 7 | wisecloud-controller metrics metrics /run/secrets/:/var/log/:/entrypoint.sh 8 | ##wisecloud-controller metrics metrics /tmp/ 9 | wisecloud-controller monitor-api monitor-api /usr/share/apk/:/run/secrets/:/tmp/ 10 | wisecloud-controller prometheus prometheus /var/run/secrets/:/etc/prometheus/ 11 | wisecloud-controller grafana grafana /run/secrets/:/usr/share/grafana/conf/:/usr/share/grafana/scripts/ 12 | ##wisecloud-controller grafana grafana /usr/share/grafana/ 13 | -------------------------------------------------------------------------------- /conf/kube-system.conf: -------------------------------------------------------------------------------- 1 | ## all 2 | ## namespace: kube-system 3 | 4 | ## namespace pod-prefix container file_or_path 5 | kube-system coredns coredns /etc/:/tmp/ 6 | kube-system kube-apiserver kube-apiserver /etc/kubernetes/:/etc/pki:/etc/ssl/:/tmp/ 7 | kube-system kube-controller-manager kube-controller-manager /etc/kubernetes/:/etc/pki:/etc/ssl/:/tmp/ 8 | kube-system kube-flannel kube-flannel /etc/kube-flannel/:/run/flannel/:/var/run/secrets/:/etc/ssl/:/tmp/ 9 | kube-system kube-proxy kube-proxy /var/run/secrets/:/tmp/ 10 | kube-system kube-scheduler kube-scheduler /etc/kubernetes/:/tmp/ 11 | -------------------------------------------------------------------------------- /conf/sample.conf: -------------------------------------------------------------------------------- 1 | ## sample 2 | ## namespace: wisecloud-controller 3 | 4 | ## namespace pod-prefix container file_or_path 5 | wisecloud-controller orchestration translator /usr/share/apk/:/run/secrets/:/app/ 6 | ##wisecloud-agent confagent confagent /usr/share/apk/:/run/secrets/:/var/run/wiserun/:/etc/crontabs/:/tmp/ -------------------------------------------------------------------------------- /doc/Kubernetes集群备份日志文件指南.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/solomonxu/k8s-backup-restore/90798283e750bfc724a5d350af07f4da89c7734c/doc/Kubernetes集群备份日志文件指南.pdf -------------------------------------------------------------------------------- /doc/Kubernetes集群资源数据的备份、恢复和自动化.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/solomonxu/k8s-backup-restore/90798283e750bfc724a5d350af07f4da89c7734c/doc/Kubernetes集群资源数据的备份、恢复和自动化.pdf --------------------------------------------------------------------------------