当前位置:网站首页>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.
边栏推荐
- What is a domain name? How to use a domain name?
- What is the relationship between IP address and domain name? How to select a domain name?
- What is the function of DNS domain name server? What is called top-level domain name
- How to register an enterprise domain name? Can an enterprise domain name be directly registered by individuals?
- Tencent security operation center integrates ueba capabilities to help enterprises ensure internal network security
- What is a domain name server? What are the types of domain name servers?
- How to build a website with a domain name? Can I build a website before applying for a domain name?
- [performance test] 3 How to calculate the number of concurrent users
- His secret script of hard technology investment
- How to register a first level domain name what is a first level domain name
猜你喜欢
Easy to understand JDBC tutorial - absolutely suitable for zero Foundation
Learning routes and materials for cloud native O & M engineers

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
随机推荐
2021, how to select a programming language?
Tencent Anxin platform was officially released, and the "Anxin agricultural product plan" was launched at the same time, supporting the growth of 100 landmark agricultural product brands in three year
What is the meaning of Xin domain name? What is the performance in network applications
How to use a Chinese domain name? Would you prefer a Chinese domain name or an English domain name?
How to buy a network domain name? Is the domain expensive
Answer questions! This article explains the automated testing framework in software testing from beginning to end
Figure 1 understand Tencent reassurance platform
What is a domain name server? What are the types of domain name servers?
What domain name is Io? The role of domain name for web address
Select MySQL database from the command prompt window
How to apply for a website domain name and what problems should be paid attention to
[performance test] 3 How to calculate the number of concurrent users
Kubernetes Chapter 1: Foundation
Edgegallery: MEC open source platform extends 5g capability to the edge
How to apply for a company domain name? Does it cost money to apply for a company domain name?
What is a company domain name? What should I pay attention to when registering a company domain name?
How to file a personal domain name? What are the benefits of domain name filing?
Net is what domain name? What is the standard of a good domain name?
How to register the company domain name mailbox? Is the operation process complicated
How to apply for a domain name for free? What is the importance of domain names?