Hello anh em! Nếu là 1 system, 1 devops hoặc 1 devops trong hiện tại và cả tương lai.
Bạn đang băn khoăn là mà muốn học 1 ngôn ngữ lập trình nào đó!
I will suggest the Golang language to you! We will research such a power full protocol and trending which is GRPC.
1) Learning Golang GPRC.
Nên mọi người nhớ like và surprise cho Channel của an ấy nhé!
Nếu được anh em comment thêm là tui từ nimtechnology đến đây he!!! hihi
Sau khi chiến xong hết các video thì mình có 1 số case thực tế!
2) The actual case study!
2.1) grpc With Insecure
Ta có file server.go
file client.go như sau
Ta thấy ở client chỉ đơn giản sử dụng khai báo như sau.

2.2) Using selfcert SSL for GRPC.
Trong bài học anh ấy đã chỉ rất củ thể và mình note thêm 1 số thứ!
chúng ta có file cert.conf
[ req ]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
C = VN
ST = HCM
L = HCM
O = Funzy.
OU = FunzyDev
emailAddress = funzydevad@gmail.com
CN = nimtechnology.com
[ req_ext ]
subjectAltName = @alt_names
[ alt_names ]
DNS.1 = localhost
DNS.2 = calculator-grpc.nimtechnology.com
Chỗ [ alt_names ] bạn sẽ lệt kê tất cả hostname hay là domain sử dụng kết nỗi giữ client và server.
vì dụ:
– localhost bạn dùng để call trên máy bạn
– calculator-grpc.nimtechnology.com bạn sự dụng để call trên dev hoặc production environment!
chúng ta có 1 file command SSLCmd.sh
openssl genrsa -out ssl/server.key 2048
openssl req -nodes -new -x509 -sha256 -days 1825 -config ssl/cert.conf -extensions 'req_ext' -key ssl/server.key -out ssl/server.crt
Khi chạy xong chúngta có mới file:

Bạn sẽ thấy file server.go như bài học:
Còn file client.go sẽ như sau:
Bạn sẽ cần lưu ý những điều sau khi mà sử dụng ssl selfcert ở client:

Làm như thầy là ngon òi.
2.2) Public GRPC via ingress-nginx.
2.2.1) Config ingress-nginx
Khi develop deploy workload GRPC lên K8s và muốn sử dụng ingress-nginx cho port GRPC đó.
đầu tiền devops cần config ingress-nginx với GPRC.
Bạn có thể tham khảo link này:
https://kubernetes.github.io/ingress-nginx/examples/grpc/
cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
name: fortune-ingress
namespace: default
spec:
ingressClassName: nginx
rules:
- host: grpctest.dev.mydomain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: go-grpc-greeter-server
port:
number: 80
tls:
# This secret must exist beforehand
# The cert must also contain the subj-name grpctest.dev.mydomain.com
# https://github.com/kubernetes/ingress-nginx/blob/master/docs/examples/PREREQUISITES.md#tls-certificates
- secretName: wildcard.dev.mydomain.com
hosts:
- grpctest.dev.mydomain.com
EOF
Để Golang GRPC working với ingress-nginx thì bạn phải tạo ingress-nginx như sau
– phải tls và public port 443.
– annotation phải khai báo:
+ nginx.ingress.kubernetes.io/ssl-redirect: “true”
+ nginx.ingress.kubernetes.io/backend-protocol: “GRPC”
2.2.2) Config client GRPC.
như mình test thì case grpc With Insecure và Using selfcert SSL for GRPC thì nó không work với ingress-nginx (Port 80 & 443 TLS) he
Ủa dậy làm sao?
2.2.2.1) Get certificates of ingress-nginx.
Bạn thấy là ingress-nginx sẽ tạo ra 1 certificates cho từng ingress 443(tls)
Nhiệm vụ của chúng ta lấy nội dung certificates ghi vào file certFile := "ssl/server.crt"
trong file certificates bạn copy tls.crt và tls.key

2.2.2.2) Insecure Skip Verify TLS
Bạn chú ý chỗ này:

Bạn sẽ tham khảo thêm links này:
https://www.banquise.org/software/grpc/three-different-ways-to-connect-two-go-services-with-grpc/