Skip to content

Commit

Permalink
feat: add deployment files for service mesh based routing
Browse files Browse the repository at this point in the history
  • Loading branch information
leonsteinhaeuser committed Nov 21, 2024
1 parent d8b80b1 commit 0a6d958
Show file tree
Hide file tree
Showing 28 changed files with 692 additions and 0 deletions.
3 changes: 3 additions & 0 deletions management_project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ spec:
- name: in-cluster
namespace: example-application-basic
server: https://kubernetes.default.svc
- name: in-cluster
namespace: example-application-basic-servicemesh
server: https://kubernetes.default.svc
- name: in-cluster
namespace: example-application-helm-basic
server: https://kubernetes.default.svc
Expand Down
55 changes: 55 additions & 0 deletions ocp/deployments/basic_servicemesh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: basic-servicemesh
labels:
argocd.argoproj.io/sync-wave: "0"
spec:
sourceNamespaces:
- example-application-basic-servicemesh
clusterResourceWhitelist:
- group: '*'
kind: '*'
destinations:
- name: in-cluster
namespace: example-application-basic-servicemesh
server: https://kubernetes.default.svc
namespaceResourceWhitelist:
- group: '*'
kind: '*'
sourceRepos:
- git@github.com:leonsteinhaeuser/rh-ocp-examples.git
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-of-apps
namespace: &ns example-application-basic-servicemesh
labels:
argocd.argoproj.io/sync-wave: "1"
spec:
destination:
namespace: *ns
server: https://kubernetes.default.svc
project: basic-servicemesh
source:
directory:
jsonnet: {}
recurse: true
path: ocp/deployments/manifests/basic
repoURL: git@github.com:leonsteinhaeuser/rh-ocp-examples.git
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
retry:
backoff:
duration: 5s
factor: 2
maxDuration: 3m0s
limit: 5
syncOptions:
- PruneLast=true
- ApplyOutOfSyncOnly=true
- ServerSideApply=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: &name number-service
namespace: &ns example-application-basic-servicemesh
labels:
argocd.argoproj.io/sync-wave: "0"
spec:
destination:
namespace: *ns
server: https://kubernetes.default.svc
project: basic-servicemesh
source:
directory:
jsonnet: {}
recurse: true
path: ocp/deployments/manifests/servicemesh/number_service
repoURL: git@github.com:leonsteinhaeuser/rh-ocp-examples.git
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
retry:
backoff:
duration: 5s
factor: 2
maxDuration: 3m0s
limit: 5
syncOptions:
- PruneLast=true
- ApplyOutOfSyncOnly=true
- ServerSideApply=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: &name status-service
namespace: &ns example-application-basic-servicemesh
labels:
argocd.argoproj.io/sync-wave: "0"
spec:
destination:
namespace: *ns
server: https://kubernetes.default.svc
project: basic-servicemesh
source:
directory:
jsonnet: {}
recurse: true
path: ocp/deployments/manifests/servicemesh/status_service
repoURL: git@github.com:leonsteinhaeuser/rh-ocp-examples.git
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
retry:
backoff:
duration: 5s
factor: 2
maxDuration: 3m0s
limit: 5
syncOptions:
- PruneLast=true
- ApplyOutOfSyncOnly=true
- ServerSideApply=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: &name view-service
namespace: &ns example-application-basic-servicemesh
labels:
argocd.argoproj.io/sync-wave: "1"
spec:
destination:
namespace: *ns
server: https://kubernetes.default.svc
project: basic-servicemesh
source:
directory:
jsonnet: {}
recurse: true
path: ocp/deployments/manifests/servicemesh/view_service
repoURL: git@github.com:leonsteinhaeuser/rh-ocp-examples.git
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
retry:
backoff:
duration: 5s
factor: 2
maxDuration: 3m0s
limit: 5
syncOptions:
- PruneLast=true
- ApplyOutOfSyncOnly=true
- ServerSideApply=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: &name number-service
labels: &labels
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
spec:
selector:
matchLabels: *labels
action: ALLOW
rules:
- from:
- source:
selector:
matchLabels:
app.kubernetes.io/name: view-service
app.kubernetes.io/instance: view-service
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
to:
- operation:
methods: ["GET"]
ports: ["8081"]
paths: ["/number"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: &name number-service
labels: &labels
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
app.kubernetes.io/version: v1
spec:
replicas: 1
selector:
matchLabels: *labels
template:
metadata:
labels: *labels
spec:
securityContext:
runAsUser: 65535
runAsGroup: 65535
automountServiceAccountToken: false
serviceAccountName: *name
containers:
- name: *name
image: ghcr.io/leonsteinhaeuser/rh-ocp-examples-number:main
imagePullPolicy: Always
ports:
- containerPort: 8081
name: http
protocol: TCP
resources:
limits:
cpu: 100m
memory: 32Mi
requests:
cpu: 10m
memory: 32Mi
livenessProbe:
httpGet:
path: /healthz
port: http
readinessProbe:
httpGet:
path: /healthz
port: http
securityContext:
runAsUser: 65535
runAsGroup: 65535
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- all
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- vservice.yaml
- network_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: &name number-service
labels: &labels
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
spec:
selector:
matchLabels: *labels
mtls:
mode: STRICT
17 changes: 17 additions & 0 deletions ocp/deployments/manifests/servicemesh/number_service/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: &name number-service
labels: &labels
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
app.kubernetes.io/version: v1
spec:
ports:
- port: 8081
targetPort: http
protocol: TCP
name: http
selector: *labels
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: &name number-service
labels:
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
37 changes: 37 additions & 0 deletions ocp/deployments/manifests/servicemesh/number_service/vservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: &name number-service
labels: &labels
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
spec:
hosts:
- *name
http:
- route:
- destination:
host: *name
subset: v1
weight: 100
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: &name number-service
labels: &labels
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
spec:
host: *name
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: &name status-service
labels: &labels
app.kubernetes.io/name: *name
app.kubernetes.io/instance: *name
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
spec:
selector:
matchLabels: *labels
action: ALLOW
rules:
- from:
- source:
selector:
matchLabels:
app.kubernetes.io/name: view-service
app.kubernetes.io/instance: view-service
app.kubernetes.io/component: api
app.kubernetes.io/part-of: microservices-demo
to:
- operation:
methods: ["GET"]
ports: ["8082"]
paths: ["/status"]
Loading

0 comments on commit 0a6d958

Please sign in to comment.