Istio-1.16.2
Create istio ingressgateway as such
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
profile: default
components:
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
service:
type: NodePort
ports:
-
name: status-port
port: 15021
protocol: TCP
targetPort: 15021
-
name: http2
port: 80
protocol: TCP
targetPort: 8080
nodePort: 30080
-
name: https
port: 443
protocol: TCP
targetPort: 8443
nodePort: 30443
-
name: tls
port: 3306
protocol: TCP
targetPort: 3306
nodePort: 30336
Create mariadb pod (envoy injected) and service
---
apiVersion: v1
kind: Pod
metadata:
name: csp
namespace: default
labels:
app: csp
sidecar.istio.io/inject: "true"
spec:
containers:
- name: mariadb
image: mariadb
args:
- --user=mysql
- --require_secure_transport=ON
- --ssl-ca=/etc/certs/root-ca.pem
- --ssl-cert=/etc/certs/server-cert.pem
- --ssl-key=/etc/certs/server-key.pem
ports:
- containerPort: 3306
volumeMounts:
- name: mariadb-ssl
mountPath: /etc/certs/
readOnly: true
volumes:
- name: mariadb-ssl
secret:
secretName: mariadb-ssl
restartPolicy: Never
---
apiVersion: v1
kind: Service
metadata:
name: csp-svc
namespace: default
spec:
selector:
app: csp
ports:
- name: tls-db
port: 3306
targetPort: 3306
type: NodePort
Create ingress gateway, virtual service and destination rule
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: csp-gateway
namespace: default
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 3306
name: tls
protocol: TLS
tls:
mode: PASSTHROUGH
hosts:
- "user1.csp.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: csp-virt-svc
namespace: default
spec:
hosts:
- "user1.csp.example.com"
gateways:
- csp-gateway
tls:
- match:
- port: 3306
sniHosts:
- user1.csp.example.com
route:
- destination:
host: csp-svc
port:
number: 3306
subset: default
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: csp-svc-dest
namespace: default
spec:
host: csp-svc
subsets:
- name: default
labels:
app: csp
---
Checking the ingressgateway routes, it is not showing the expected route
$ ~/istio-1.16.2/bin/istioctl proxy-config routes istio-ingressgateway-b7dd4d8c-nhdhp.istio-system
NAME DOMAINS MATCH VIRTUAL SERVICE
* /stats/prometheus*
* /healthz/ready*
Istioctl analyze gives no error. Pod istio proxy logs look normal
2023-03-19T15:38:10.400761Z info Readiness succeeded in 564.633686ms
2023-03-19T15:38:10.400958Z info Envoy proxy is ready
2023-03-19T16:07:52.324533Z info xdsproxy connected to upstream XDS server: istiod.istio-system.svc:15012
My objective is to use TLS-enabled MySQL/MariaDB to do SNI routing in istio. The above example is 1 instance of mariadb pod+service, I will have many.
How can I achieve this? It seems possible from here