forked from wardviaene/kubernetes-course
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75b20b4
commit f06430b
Showing
2 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: "authentication.istio.io/v1alpha1" | ||
kind: "Policy" | ||
metadata: | ||
name: "jwt-example" | ||
spec: | ||
targets: | ||
- name: hello | ||
peers: | ||
- mtls: {} | ||
origins: | ||
- jwt: | ||
issuer: "[email protected]" | ||
jwksUri: "http://auth.kubernetes.newtech.academy/.well-known/jwks.json" | ||
principalBinding: USE_ORIGIN | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: Gateway | ||
metadata: | ||
name: helloworld-gateway | ||
spec: | ||
selector: | ||
istio: ingressgateway # use istio default controller | ||
servers: | ||
- port: | ||
number: 80 | ||
name: http | ||
protocol: HTTP | ||
hosts: | ||
- "*" | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: VirtualService | ||
metadata: | ||
name: helloworld-auth | ||
spec: | ||
hosts: | ||
- "auth.kubernetes.newtech.academy" | ||
gateways: | ||
- helloworld-gateway | ||
http: | ||
- route: | ||
- destination: | ||
host: auth.default.svc.cluster.local | ||
port: | ||
number: 8080 | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: VirtualService | ||
metadata: | ||
name: helloworld-hello | ||
spec: | ||
hosts: | ||
- "hello.kubernetes.newtech.academy" | ||
gateways: | ||
- helloworld-gateway | ||
http: | ||
- route: | ||
- destination: | ||
host: hello.default.svc.cluster.local | ||
port: | ||
number: 8080 | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: auth | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: auth | ||
version: v1 | ||
spec: | ||
containers: | ||
- name: auth | ||
image: wardviaene/http-echo | ||
env: | ||
- name: TEXT | ||
value: this is the authentication service | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: auth | ||
labels: | ||
app: auth | ||
spec: | ||
selector: | ||
app: auth | ||
ports: | ||
- name: http | ||
port: 8080 | ||
targetPort: 8080 | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: hello | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: hello | ||
version: v1 | ||
spec: | ||
containers: | ||
- name: hello | ||
image: wardviaene/http-echo | ||
env: | ||
- name: TEXT | ||
value: Hello, you can only reach this service when authenticated | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: hello | ||
labels: | ||
app: hello | ||
spec: | ||
selector: | ||
app: hello | ||
ports: | ||
- name: http | ||
port: 8080 | ||
targetPort: 8080 | ||
### | ||
### Enable TLS | ||
### | ||
--- | ||
apiVersion: authentication.istio.io/v1alpha1 | ||
kind: "MeshPolicy" | ||
metadata: | ||
name: "default" | ||
spec: | ||
peers: | ||
- mtls: {} | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: DestinationRule | ||
metadata: | ||
name: "enable-mtls" | ||
namespace: "default" # even though we specify a namespace, this rule applies to all namespaces | ||
spec: | ||
host: "*.local" | ||
trafficPolicy: | ||
tls: | ||
mode: ISTIO_MUTUAL | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: DestinationRule | ||
metadata: | ||
name: "api-server" | ||
spec: | ||
host: "kubernetes.default.svc.cluster.local" | ||
trafficPolicy: | ||
tls: | ||
mode: DISABLE |