Skip to content

Instantly share code, notes, and snippets.

#Create namespace for control plane
oc new-project control-plane --display-name="Control Plane"
#Create control plane
oc create -f \
https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/setup-ossm/smcp.yaml -n control-plane
#Wait couple of minutes for operator to creating control plane
#You can check status by
oc get smcp basic-install -n control-plane
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: frontend-virtual-service
spec:
hosts:
- frontend.apps.SUBDOMAIN
gateways:
- control-plane/wildcard-gateway
http:
#Create Destination Rule - backend service
oc apply -f https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/config/backend-destination-rule.yaml
#Create Virtual Service - backend service
oc apply -f https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/config/backend-virtual-service.yaml
#Get OpenShift Domain from Console's URL this default subdomain to "apps"
SUBDOMAIN=$(oc whoami --show-console | awk -F'apps.' '{print $2}')
DOMAIN="apps.${SUBDOMAIN}"
#Create Destination Rule
oc apply -f https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/config/frontend-destination-rule.yaml
#Create Gateway - replaced DOMAIN cluster to yaml
curl -s https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/config/gateway.yaml|sed 's/DOMAIN/'"$DOMAIN"'/'| oc apply -f -
oc apply -f https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/config/backend-peer-authentication.yaml
oc apply -f https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/config/backend-destination-rule-mtls.yaml
#Pause Rollout
oc rollout pause deployment backend-v1 -n data-plane
#Set Readiness Probe
oc set probe deployment backend-v1 --readiness --get-url=http://:8080/health/ready --failure-threshold=1 --initial-delay-seconds=5 --period-seconds=5 -n data-plane
#Set Liveness Probe
oc set probe deployment backend-v1 --liveness --get-url=http://:8080/health/live --failure-threshold=1 --initial-delay-seconds=5 --period-seconds=5 -n data-plane
#Resume Rollout
oc patch deployment/backend-v1 -p '{"spec":{"template":{"metadata":{"annotations":{"sidecar.istio.io/rewriteAppHTTPProbers":"true"}}}}}'
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: backend
namespace: data-plane
spec:
selector:
matchLabels:
app: backend
mtls:
oc apply -f https://raw.githubusercontent.com/voraviz/openshift-service-mesh-ingress-mtls/main/apps/deployment.yaml -n data-plane