Skip to content

Instantly share code, notes, and snippets.

@selcukusta
Last active January 27, 2020 09:34
Show Gist options
  • Save selcukusta/98d43169336655973f073c004e0bc818 to your computer and use it in GitHub Desktop.
Save selcukusta/98d43169336655973f073c004e0bc818 to your computer and use it in GitHub Desktop.
  1. Aşağıdaki kod bloğu ile CSR (Certificate Signing Request) dosyası ve key dosyası oluşturulur. NOT: .key uzantılı dosya dışarıya sızdırılmamalıdır!
openssl req -new -newkey rsa:2048 -nodes -keyout www_yourdomain_com.key -out www_yourdomain_com.csr
  1. .csr uzantılı dosya sertifika temin edilecek firmaya iletilir ve içeriği aşağıdakine benzer - ya da aşağıdaki ile aynı - .zip uzantılı dosya edinilir.
! PRIVATE KEY INFO !.txt
CER - CRT Files
Choosing the Right Files to Install.txt
Plain Text Files
  1. Bundle edilmiş dosya ile domain ssl dosyası tek bir dosyada birleştirilir (Bu dosyalar, SSL hizmeti alınan firmadan gelen içerikte bulunur).
cd CER - CRT Files
cat www_yourdomain_com.crt My_CA_Bundle.ca-bundle > www_yourdomain_com-bundle.crt
  1. Aşağıdaki kod bloğu ile .key ve .crt uzantılı dosyaları kullanarak sertifika secret'ı oluşturulur.
kubectl create -n istio-system secret tls istio-ingressgateway-[YOUR_DOMAIN_NAME]-certs --key www_yourdomain_com.key --cert www_yourdomain_com-bundle.crt
  1. Aşağıdaki kod bloğu ile Kubernetes için patch dosyası oluşturulur ve bu dosya ile sertifikaların, Istio'nun ingress-gateway pod'una mount edilmesi için gerekli script dosyası hazırlanır.
cat > tls-patch.json <<EOF
[{
  "op": "add",
  "path": "/spec/template/spec/containers/0/volumeMounts/0",
  "value": {
    "mountPath": "/etc/istio/ingressgateway-[YOUR-DOMAIN-NAME]-certs",
    "name": "ingressgateway-[YOUR-DOMAIN-NAME]-certs",
    "readOnly": true
  }
},
{
  "op": "add",
  "path": "/spec/template/spec/volumes/0",
  "value": {
  "name": "ingressgateway-[YOUR-DOMAIN-NAME]-certs",
    "secret": {
      "secretName": "istio-ingressgateway-[YOUR-DOMAIN-NAME]-certs",
      "optional": true
    }
  }
}]
EOF
  1. Aşağıdaki kod bloğu ile patch uygulanır.
kubectl -n istio-system patch --type=json deploy istio-ingressgateway -p "$(cat tls-patch.json)"
  1. Aşağıdaki kod bloğu ile tls.crt ve tls.key dosyalarının oluşturulduğundan emin olunur.
kubectl exec -it -n istio-system $(kubectl -n istio-system get pods -l istio=ingressgateway -o jsonpath='{.items[0].metadata.name}') -- ls -al /etc/istio/ingressgateway-[YOUR-APP-NAME]-certs

Çıktının aşağıdaki şekilde olması beklenmektedir;

drwxr-xr-x 2 root root   80 Jan 27 06:34 ..2020_01_27_06_34_21.451799771
lrwxrwxrwx 1 root root   31 Jan 27 06:34 ..data -> ..2020_01_27_06_34_21.451799771
lrwxrwxrwx 1 root root   14 Jan 27 06:34 tls.crt -> ..data/tls.crt
lrwxrwxrwx 1 root root   14 Jan 27 06:34 tls.key -> ..data/tls.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment