Skip to content

Instantly share code, notes, and snippets.

@dbones
Created July 1, 2020 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbones/02f4782c2447fa856aaad516268caf47 to your computer and use it in GitHub Desktop.
Save dbones/02f4782c2447fa856aaad516268caf47 to your computer and use it in GitHub Desktop.
istio self cert, prefix routing, gateway in another namespace and virtual service routing to a k8s service
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: selfsigning-issuer
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: awesome-io
namespace: istio-system
spec:
secretName: awesome-io
# The use of the common name field has been deprecated since 2000
commonName: "awesome.io"
organization:
- Awesome inc
dnsNames:
- awesome.io
keySize: 2048
keyAlgorithm: rsa
keyEncoding: pkcs1
issuerRef:
name: selfsigning-issuer
kind: ClusterIssuer
privateKey:
rotationPolicy: Always
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: awesome-io-gateway
namespace: istio-system
spec:
selector:
istio: ingressgateway # use istio default ingress gateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: awesome-io # must be the same as secret
hosts:
- "awesome.io"
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "awesome.io"
apiVersion: v1
kind: Namespace
metadata:
name: weather
labels:
istio-injection: enabled
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: weather
name: weather
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: weather
name: weather
spec:
replicas: 1
selector:
matchLabels:
app: weather
version: v1
template:
metadata:
labels:
app: weather
version: v1
spec:
serviceAccountName: weather
containers:
- image: docker.io/dbones/weather
imagePullPolicy: IfNotPresent
name: weather
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
namespace: weather
name: weather
labels:
app: weather
spec:
ports:
- name: http
port: 80
targetPort: 80
selector:
app: weather
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
namespace: weather
name: weather
spec:
hosts:
- "*"
gateways:
- istio-system/awesome-io-gateway
http:
- match:
- uri:
prefix: "/weather/"
- uri:
prefix: "/weather"
rewrite:
uri: "/"
route:
- destination:
port:
number: 80
host: weather
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment