当前位置:网站首页>Script updates CLB type ingress Certificate in tke cluster
Script updates CLB type ingress Certificate in tke cluster
2022-06-24 05:43:00 【Nieweixing】
Usually we tke Carry out inside 7 Layer service exposure , It can be used nginx ingress and clb Type of ingress, If you use it clb type ingress, Need to be in tke This way secret Configure the certificate on Tencent cloud , When your certificate expires or does not exist , Configuration error , It can lead to ingress Synchronize rules to clb Failure , As a result, an exception occurs when accessing the domain name , At this time, we need to be right in tke This update ingress Certificate id To solve this problem .
Let's use a simple script to update with one click ingress Certificate id.
Script one click Update ingress The certificate must have the following conditions
- from https://console.cloud.tencent.com/ssl Obtain correct and valid certificates id
- The client machine can use kubectl Access cluster
When the above conditions are met , Here we only need to copy the following script to the corresponding machine for execution ,update-ingress-certificate-id.sh The script is as follows
Script tips :shell Introduce variables in single quotation marks , You only need to embed single quotation marks inside single quotation marks to use variables
#!/bin/bash
ingress_name=$1
ns=$2
certificate_id=$3
if [ $# = 0 ];then
echo "Run 'sh update-ingress-certificate-id.sh --h' for more information on a command."
fi
if [[ $1 = "--h" ]];then
echo "Please enter the first parameter is the name of ingress, the second parameter is the namespace, and the third parameter is the certificate id.
Usage: sh update-ingress-certificate-id.sh [ingress_name] [namespace] [certificate_id]"
fi
main(){
secret_name=`kubectl get ingress -n $ns $ingress_name -o=jsonpath='{.spec.tls[*].secretName}'`
base64_result=`echo -n $certificate_id | base64`
kubectl patch secret $secret_name -n $ns --type='json' -p='[{"op": "replace", "path": "/data/qcloud_cert_id", "value":'$base64_result'}]'
}
if [ $# = 3 ];then
main
fi Let's test the script , Suppose I want to update the correct Certificate id yes lI7vOSLM, First look at the present secret Certificate id How much is the
[[email protected] script]# kubectl get ingress -n ingress-test test-ingress -o=jsonpath='{.spec.tls[*].secretName}' grpc-leq8zgsw [[email protected] script]# kubectl get secret grpc-leq8zgsw -o=jsonpath='{.data.qcloud_cert_id}' -n ingress-test | base64 -d lEq8zGsW
current ingress certificate id yes lEq8zGsW, Let's update it with a script
[[email protected] script]# sh -x update-ingress-certificate-id.sh test-ingress ingress-test lI7vOSLM + ingress_name=test-ingress + ns=ingress-test + certificate_id=lI7vOSLM + '[' 3 = 0 ']' + [[ test-ingress = \-\-\h ]] + '[' 3 = 3 ']' + main ++ kubectl get ingress -n ingress-test test-ingress '-o=jsonpath={.spec.tls[*].secretName}' + secret_name=grpc-leq8zgsw ++ base64 ++ echo -n lI7vOSLM + base64_result=bEk3dk9TTE0= + echo bEk3dk9TTE0= bEk3dk9TTE0= + kubectl patch secret grpc-leq8zgsw -n ingress-test --type=json '-p=[{"op": "replace", "path": "/data/qcloud_cert_id", "value":bEk3dk9TTE0=}]' secret/grpc-leq8zgsw patched
The script has been updated successfully , We get the certificate id, See if the certificate is correct idlI7vOSLM
[[email protected] script]# kubectl get ingress -n ingress-test test-ingress -o=jsonpath='{.spec.tls[*].secretName}' grpc-leq8zgsw [[email protected] script]# kubectl get secret grpc-leq8zgsw -o=jsonpath='{.data.qcloud_cert_id}' -n ingress-test | base64 -d lI7vOSLM
From the results obtained , here ingress The certificate has been successfully updated to lI7vOSLM.
边栏推荐
- Distributed background task load balancing
- [experience sharing] 1.39 million problem solving report of Tencent's internal track
- How to apply for a company domain name? Does it cost money to apply for a company domain name?
- How to check the school domain name? Are all school domain names unified?
- What is domain name filing? What is the role of domain name filing?
- Answer questions! This article explains the automated testing framework in software testing from beginning to end
- Disaster recovery series (III) -- cloud network disaster recovery construction
- Threat discovery under automated data analysis
- His secret script of hard technology investment
- How to build a website after registering a domain name? Can individuals register domain names to build websites?
猜你喜欢

How should we learn cloud native in 2022?
What cloud native knowledge should programmers master?

Answer questions! This article explains the automated testing framework in software testing from beginning to end
Learning routes and materials for cloud native O & M engineers
Easy to understand JDBC tutorial - absolutely suitable for zero Foundation
随机推荐
How to build a website after registering a domain name? Can individuals register domain names to build websites?
It is necessary to do the industry of waiting insurance evaluation. Let's see if you are on the list
PV and PVC analysis and use in kubernetes
Creating a database using mysqladmin
What is a company domain name? What should I pay attention to when registering a company domain name?
How to build a website with a domain name? What steps need to be taken?
How to register an overseas domain name what should be paid attention to when registering a domain name
Pylin tool usage
How to make a secondary domain name? What is the purpose of a secondary domain name?
How to register domain name and web address? What is the domain name and URL?
What domain name is top? What are the advantages of the top domain name?
How to register a domain name how to make the domain name short and easy to remember
How to buy a domain name? Do you need to file a domain name purchase?
Error 0xc0000013, 0xc000007b, etc. due to the conflict between the CD-ROM drive letter and the drive letter in the business program path
How to get a secondary domain name? What does a secondary domain name mean?
What is domain name resolution? How much does domain name registration cost
How to do domain name resolution? What does domain name resolution mean?
Oceanus practice consumption CMQ subject model data source
The instrument industry builds the supplier SRM mode to manage the development of manufacturers + users
How about the work domain name? Does the work domain name need real name authentication?