当前位置:网站首页>Store and guarantee rancher data based on Minio objects
Store and guarantee rancher data based on Minio objects
2022-07-28 14:40:00 【InfoQ】
Preface

precondition
- Rancher:2.6.6
- k8s:v1.23.7
MinIO Rapid deployment
MinIO Introduce
- Cloud native: Conform to the architecture and construction process of all cloud native clouds , It also includes the latest cloud computing technologies and concepts . It includes support for Kubernetes 、 Micro server and multi tenant container technology , Let the object store for Kubernetes More friendly .
- High performance: On standard hardware , read / The writing speed is as high as 183 GB / second and 171 GB / second , Have higher throughput and lower latency .
- Scalable: Expansion starts with a single cluster , The cluster can work with other MinIO Cluster Federation to create a global namespace , And can span multiple different data centers when needed .
- Easy to operate: Simple deployment , Simplifies the process of using object storage , Support multiple platforms to run .
MinIO Deploy
- One click generation ssl Self signed certificate script , Save the following script to
create-cert.shIn file .
#!/bin/bash -e
help ()
{
echo ' ================================================================ '
echo ' --ssl-domain: Generate ssl The primary domain name required for the certificate , If not specified, it defaults to www.rancher.local, If it is ip Access the service , You can ignore ;'
echo ' --ssl-trusted-ip: commonly ssl The certificate only trusts domain access requests , Sometimes you need to use ip To visit server, Then I need to give ssl Certificate add extension IP, Multiple IP Separated by commas ;'
echo ' --ssl-trusted-domain: If you want to access multiple domains , Then add the extended domain name (SSL_TRUSTED_DOMAIN), Multiple extended domain names are separated by commas ;'
echo ' --ssl-size: ssl Number of encrypted bits , Default 2048;'
echo ' --ssl-cn: Country code (2 It's a letter code ), Default CN;'
echo ' Examples of use :'
echo ' ./create_self-signed-cert.sh --ssl-domain=www.test.com --ssl-trusted-domain=www.test2.com \ '
echo ' --ssl-trusted-ip=1.1.1.1,2.2.2.2,3.3.3.3 --ssl-size=2048 --ssl-date=3650'
echo ' ================================================================'
}
case "$1" in
-h|--help) help; exit;;
esac
if [[ $1 == '' ]];then
help;
exit;
fi
CMDOPTS="$*"
for OPTS in $CMDOPTS;
do
key=$(echo ${OPTS} | awk -F"=" '{print $1}' )
value=$(echo ${OPTS} | awk -F"=" '{print $2}' )
case "$key" in
--ssl-domain) SSL_DOMAIN=$value ;;
--ssl-trusted-ip) SSL_TRUSTED_IP=$value ;;
--ssl-trusted-domain) SSL_TRUSTED_DOMAIN=$value ;;
--ssl-size) SSL_SIZE=$value ;;
--ssl-date) SSL_DATE=$value ;;
--ca-date) CA_DATE=$value ;;
--ssl-cn) CN=$value ;;
esac
done
# CA Related configuration
CA_DATE=${CA_DATE:-3650}
CA_KEY=${CA_KEY:-cakey.pem}
CA_CERT=${CA_CERT:-cacerts.pem}
CA_DOMAIN=cattle-ca
# ssl Related configuration
SSL_CONFIG=${SSL_CONFIG:-$PWD/openssl.cnf}
SSL_DOMAIN=${SSL_DOMAIN:-'www.rancher.local'}
SSL_DATE=${SSL_DATE:-3650}
SSL_SIZE=${SSL_SIZE:-2048}
## Country code (2 It's a letter code ), Default CN;
CN=${CN:-CN}
SSL_KEY=$SSL_DOMAIN.key
SSL_CSR=$SSL_DOMAIN.csr
SSL_CERT=$SSL_DOMAIN.crt
echo -e "\033[32m ---------------------------- \033[0m"
echo -e "\033[32m | Generate SSL Cert | \033[0m"
echo -e "\033[32m ---------------------------- \033[0m"
if [[ -e ./${CA_KEY} ]]; then
echo -e "\033[32m ====> 1. It is found that CA Private key , Backup "${CA_KEY}" by "${CA_KEY}"-bak, Then recreate \033[0m"
mv ${CA_KEY} "${CA_KEY}"-bak
openssl genrsa -out ${CA_KEY} ${SSL_SIZE}
else
echo -e "\033[32m ====> 1. Generate a new CA Private key ${CA_KEY} \033[0m"
openssl genrsa -out ${CA_KEY} ${SSL_SIZE}
fi
if [[ -e ./${CA_CERT} ]]; then
echo -e "\033[32m ====> 2. It is found that CA certificate , Backup first "${CA_CERT}" by "${CA_CERT}"-bak, Then recreate \033[0m"
mv ${CA_CERT} "${CA_CERT}"-bak
openssl req -x509 -sha256 -new -nodes -key ${CA_KEY} -days ${CA_DATE} -out ${CA_CERT} -subj "/C=${CN}/CN=${CA_DOMAIN}"
else
echo -e "\033[32m ====> 2. Generate a new CA certificate ${CA_CERT} \033[0m"
openssl req -x509 -sha256 -new -nodes -key ${CA_KEY} -days ${CA_DATE} -out ${CA_CERT} -subj "/C=${CN}/CN=${CA_DOMAIN}"
fi
echo -e "\033[32m ====> 3. Generate Openssl The configuration file ${SSL_CONFIG} \033[0m"
cat > ${SSL_CONFIG} <<EOM
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
[req_distinguished_name]
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth, serverAuth
EOM
if [[ -n ${SSL_TRUSTED_IP} || -n ${SSL_TRUSTED_DOMAIN} || -n ${SSL_DOMAIN} ]]; then
cat >> ${SSL_CONFIG} <<EOM
subjectAltName = @alt_names
[alt_names]
EOM
IFS=","
dns=(${SSL_TRUSTED_DOMAIN})
dns+=(${SSL_DOMAIN})
for i in "${!dns[@]}"; do
echo DNS.$((i+1)) = ${dns[$i]} >> ${SSL_CONFIG}
done
if [[ -n ${SSL_TRUSTED_IP} ]]; then
ip=(${SSL_TRUSTED_IP})
for i in "${!ip[@]}"; do
echo IP.$((i+1)) = ${ip[$i]} >> ${SSL_CONFIG}
done
fi
fi
echo -e "\033[32m ====> 4. Build service SSL KEY ${SSL_KEY} \033[0m"
openssl genrsa -out ${SSL_KEY} ${SSL_SIZE}
echo -e "\033[32m ====> 5. Build service SSL CSR ${SSL_CSR} \033[0m"
openssl req -sha256 -new -key ${SSL_KEY} -out ${SSL_CSR} -subj "/C=${CN}/CN=${SSL_DOMAIN}" -config ${SSL_CONFIG}
echo -e "\033[32m ====> 6. Build service SSL CERT ${SSL_CERT} \033[0m"
openssl x509 -sha256 -req -in ${SSL_CSR} -CA ${CA_CERT} \
-CAkey ${CA_KEY} -CAcreateserial -out ${SSL_CERT} \
-days ${SSL_DATE} -extensions v3_req \
-extfile ${SSL_CONFIG}
echo -e "\033[32m ====> 7. Certificate production completed \033[0m"
echo
echo -e "\033[32m ====> 8. With YAML Format output result \033[0m"
echo "----------------------------------------------------------"
echo "ca_key: |"
cat $CA_KEY | sed 's/^/ /'
echo
echo "ca_cert: |"
cat $CA_CERT | sed 's/^/ /'
echo
echo "ssl_key: |"
cat $SSL_KEY | sed 's/^/ /'
echo
echo "ssl_csr: |"
cat $SSL_CSR | sed 's/^/ /'
echo
echo "ssl_cert: |"
cat $SSL_CERT | sed 's/^/ /'
echo
echo -e "\033[32m ====> 9. additional CA Certificate to Cert file \033[0m"
cat ${CA_CERT} >> ${SSL_CERT}
echo "ssl_cert: |"
cat $SSL_CERT | sed 's/^/ /'
echo
echo -e "\033[32m ====> 10. Rename Service Certificate \033[0m"
echo "cp ${SSL_DOMAIN}.key tls.key"
cp ${SSL_DOMAIN}.key tls.key
echo "cp ${SSL_DOMAIN}.crt tls.crt"
cp ${SSL_DOMAIN}.crt tls.crtchmod +x create-cert.sh
./create-tls.sh --ssl-domain=minio.zerchin.xyz --ssl-size=2048 --ssl-date=3650--ssl-domain- establish minio Folder .
mkdir -p /minio/data
mkdir -p /minio/certs/CAs- Copy the created certificate to the directory of the certificate .
cp tls.crt /minio/certs/public.crt
cp tls.key /minio/certs/private.key
cp cacerts.pem /minio/certs/CAs/cacerts.pemdocker runCommand to start MinIO.
docker run -itd --net host --name minio --restart unless-stopped -v /minio/data:/data -v /minio/certs:/certs -e MINIO_ROOT_USER=admin -e MINIO_ROOT_PASSWORD=Rancher123 minio/minio server /data --console-address minio.zerchin.xyz:443 --address minio.zerchin.xyz:9000 --certs-dir /certsMINIO_ROOT_USER: Set up administrator users .
MINIO_ROOT_PASSWORD: Administrator user password .
--console-address:MinIO Management platform address , When a certificate is detected , Automatically configured to https.
--address: Address of actual data transmission .
--certs-dir: Set the certificate directory , The default is${HOME}/.minio/certsThis directory , Here is the directory we mount . Note that the name of the certificate and secret key must bepublic.crtandprivate.key. If there is self signature CA certificate , You need to put it under this pathCAsCatalog .
MinIO Use
- visit MinIO.
https://minio.zerchin.xyzMINIO_ROOT_USERMINIO_ROOT_PASSWORD
- establish Bucket, Name it backup.



- Create access users .



adopt MinIO Backup and recovery Rancher Downstream of management K8s colony
etcd The snapshot backup
- Edit downstream cluster , stayEtcd Backup storageNext , choice s3.

S3 Bucket Name:S3 Bucket name for .
S3 Folder: The folder under the bucket . If it is not filled in, the data will be stored directly in the root directory of the bucket .
S3 Region Endpoint: Appoint S3 Endpoint URL Address , This corresponds to the front--addressExposed address
Access Key:S3 Of accessKey
Secret Key:S3 Of secretKey
Customize CA certificate: Custom certificate authentication , Used to connect to S3 Endpoint .
- Create downstream cluster snapshots .
- After the cluster is updated , We enter the cluster , staySnapshotsNext , Click onCreate a snapshot nowButton , Will automatically help us create etcd snapshot , And save to remote MinIO On storage .

- Verify that the snapshot is stored in MinIO in .

etcd Snapshot recovery
- Snapshot based recovery k8s colony .


- Restore only etcd data .
- At the same time recover k8s Version and etcd data .
- At the same time, restore the cluster configuration 、k8s Version and etcd data .

adopt MinIO Backup and recovery Rancher
rancher-backuprancher-backupRancher Backup Deploy
- install Rancher Backup.
- First go to local In the cluster ( namely rancher The cluster ), stay application & Application market - Charts Under the navigation bar , Click on Rancher Backups App start installation .

- Click oninstall, What's installed here is 2.1.2 edition .

- Choose to install to
Systemproject , And then clicknext step

- Select the default storage location , First chooseNo default storage location, Click oninstallAfter button , Start installation .

- Wait a few minutes , etc. rancher backup Of pod start-up .( Depending on the speed of pulling the image )

Create the first one Backup
- Create a secret, choice Opaque type .

- Name it
minio-cerd, Add two pieces of data , RespectivelyaccessKeyandsecretKey, And save .

- stay Rancher Backup - Backups Under the navigation bar , Click on the rightestablishButton , Create the first oneBackup.

- Storage location selectionUse Amazon S3 Compatible object storage services.

Credential ciphertext: Choose the minio Ciphertext .
Bucket name:S3 Bucket name for .
Folder: The folder under the bucket . If it is not filled in, the data will be stored directly in the root directory of the bucket .
Endpoint: Appoint S3 Endpoint URL Address , This corresponds to the front--addressExposed address
Endpoint CA: Self signed certificate needs to be added CA certificate , Use it here first base64 Fill in after coding .
- After the save , Will automatically initiate rancher Backup request , At the same time, save the backup data file to S3 On storage , When displayedCompletedIt indicates that the backup has been successful .( Record the backup file name , Recovery will use )

- Sign in MinIO, Check that the backup file has been saved .

be based on Backup recovery Rancher
- install RKE colony .
- Need to install with current Rancher The same version of the cluster , The installation method can be referred to Rancher Official documents , One is ready here RKE colony , I won't go into that .
- add to Rancher-Backup Corresponding Helm repo.
helm repo add rancher-charts https://charts.rancher.io
helm repo update- install rancher-backup Helm chart, Specify the same rancher-backup edition , Choose here 2.1.2 edition .
helm install rancher-backup-crd rancher-charts/rancher-backup-crd -n cattle-resources-system --create-namespace --version 2.1.2
helm install rancher-backup rancher-charts/rancher-backup -n cattle-resources-system --version 2.1.2- see rancher-backup pod Is the status ready .
# kubectl -n cattle-resources-system get pods
NAME READY STATUS RESTARTS AGE
rancher-backup-74779d9dfd-vjdth 1/1 Running 0 27s- To write
minio-cerd-secret.yamlfile , To configure MinIO Access key .
apiVersion: v1
kind: Secret
metadata:
name: minio-cred
namespace: cattle-resources-system
type: Opaque
data:
accessKey: <s3 access key base64 code >
secretKey: <s3 secret key base64 code >kubectl create -f minio-cerd-secret.yaml- To write Restore yaml file , Name it
restore.yaml.
apiVersion: resources.cattle.io/v1
kind: Restore
metadata:
name: restore-minio
spec:
backupFilename: minio-backup-da0178a9-bf73-4b4d-a615-863bf7e46689-2022-07-18T17-46-43Z.tar.gz
prune: false
storageLocation:
s3:
credentialSecretName: minio-cred
credentialSecretNamespace: cattle-resources-system
bucketName: backup
folder: rancher-backup
endpoint: minio.zerchin.xyz:9000
endpointCA: |-
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURGVENDQWYyZ0F3SUJBZ0lKQUp1Z1pWNVFN
...
...
...
L2xlRFdzNThVd3FvYWtVc0diQT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KbackupFilenamekubectl create -f restore.yaml- see Restore state .
kubectl get restore
kubectl logs -n cattle-resources-system --tail 100 -f rancher-backup-xxx-xxx# kubectl get restores.resources.cattle.io
NAME BACKUP-SOURCE BACKUP-FILE AGE STATUS
restore-minio S3 minio-backup-da0178a9-bf73-4b4d-a615-863bf7e46689-2022-07-18T17-46-43Z.tar.gz 74s Completed- Next use Helm install Rancher.
helm install rancher rancher-stable/rancher -n cattle-system --set xxx --set xxx- Switch Rancher Front end load balancing /DNS Resolve to new Rancher Node .
- Sign in Rancher UI Interface , Visit normal , The recovery is successful .

边栏推荐
猜你喜欢

zabbix分布式

OKR与GRAD

如何只降3D相机不降UI相机的分辨率

How to effectively conduct the review meeting (Part 1)?

2022年安全员-A证操作证考试题库模拟考试平台操作

When Xcode writes swiftui code, it is a small trap that compiles successfully but causes the preview to crash

The method of implementing simple student achievement management system with C language

Recommended super easy-to-use mobile screen recording software

复制excel行到指定行

十、时间戳
随机推荐
Hcip day 12
Hand in hand from 0 to a "Nuggets special attention" Google plug-in, 5000 words detailed vue3 responsive principle, the advantages, disadvantages and choices of several cache read-write schemes, flyin
为自定义属性包装类型添加类 @Published 的能力
C # read INI file and key value pair operation
SwiftUI 布局 —— 尺寸( 上 )
Excel VBA password free view VBE encryption code
Afnetworking crash course
如何有效进行回顾会议(上)?
Excel VBA 开发过程中遇到的一些问题,解决方案,持续更新
Force deduction solution summary 1331 array sequence number conversion
MQTT入门级简单介绍与使用
linux安装redis
2022 low voltage electrician examination questions and answers
@Solution to DS ('slave') multi data source compatible transaction problem
[ecmascript6] modularization
为 @CloudStorage 添加了类 @Published 的能力
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
SwiftUI 布局 —— 尺寸( 下 )
What is gossip (E-Net gossip)
Thrift 序列化协议浅析
