실습
Prerequisite
Installation
Ingress Gateway
TLS
cat <<'EOF' | istioctl install -y -f - apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: components: ingressGateways: - name: istio-ingressgateway enabled: true k8s: serviceAnnotations: service.beta.kubernetes.io/aws-load-balancer-type: external service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: instance service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing service.beta.kubernetes.io/aws-load-balancer-attributes: load_balancing.cross_zone.enabled=true service: externalTrafficPolicy: Cluster loadBalancerSourceRanges: - 0.0.0.0/0 EOFopenssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \ -subj '/CN=example.com' -keyout ca-key.pem -out ca-cert.pemopenssl req -newkey rsa:2048 -nodes \ -subj "/CN=*.example.com" -keyout example.com.key -out example.com.csropenssl x509 -req -sha256 -days 365 -CA ca-cert.pem -CAkey ca-key.pem \ -set_serial 0 -in example.com.csr -out example.com.crtkubectl create -n istio-system secret tls example-com \ --key=example.com.key --cert=example.com.crtcat <<EOF | kubectl apply -f - apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: istio-gateway spec: selector: istio: ingressgateway servers: - port: number: 443 name: https protocol: HTTPS tls: mode: SIMPLE credentialName: example-com hosts: - "*" EOFcat <<EOF | kubectl apply -f - apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: nginx spec: hosts: - "nginx.example.com" gateways: - istio-gateway http: - match: - uri: prefix: / route: - destination: host: nginx port: number: 80 EOFcat <<EOF | kubectl apply -f - apiVersion: apps/v1 kind: Deployment metadata: labels: app: nginx name: nginx spec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: ports: - port: 80 selector: app: nginx EOFcurl -H "Host: nginx.example.com" --cacert ca-cert.pem --insecure -v \ https://$(kubectl -n istio-system get svc istio-ingressgateway -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}')cat <<EOF | kubectl apply -f - apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: istio-gateway spec: selector: istio: ingressgateway servers: - port: number: 80 name: http protocol: HTTP tls: httpsRedirect: true hosts: - "*" - port: number: 443 name: https protocol: HTTPS tls: mode: SIMPLE credentialName: example-com hosts: - "*" EOFcurl -H "Host: nginx.example.com" --cacert ca-cert.pem --insecure -v -L \ http://$(kubectl -n istio-system get svc istio-ingressgateway -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}')cat <<EOF | kubectl apply -f - apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: istio-gateway spec: selector: istio: ingressgateway servers: - port: number: 80 name: http protocol: HTTP hosts: - "*" - port: number: 443 name: https protocol: HTTPS tls: mode: SIMPLE credentialName: example-com hosts: - "*" EOFcat <<EOF | kubectl apply -f - apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: nginx spec: hosts: - "nginx.example.com" gateways: - istio-gateway http: - match: - scheme: exact: http redirect: scheme: https redirectCode: 308 - match: - uri: prefix: / route: - destination: host: nginx port: number: 80 EOFcurl -H "Host: nginx.example.com" --cacert ca-cert.pem --insecure -v \ https://$(kubectl -n istio-system get svc istio-ingressgateway -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}')curl -H "Host: nginx.example.com" --cacert ca-cert.pem --insecure -v -L \ http://$(kubectl -n istio-system get svc istio-ingressgateway -o=jsonpath='{.status.loadBalancer.ingress[0].hostname}')kubectl delete deploy nginx kubectl delete svc nginx kubectl delete virtualservices.networking.istio.io nginx kubectl delete gateways.networking.istio.io istio-gateway kubectl delete -n istio-system secret example-com istioctl x uninstall -y --purge
TLS with NLB
Authorization
Service Entry
Introduction
Deep Dive
External HTTPS Proxy
Last updated