Skip to content

Commit

Permalink
Refactor Kustomize components (service-accounts, shopping-assistant) (#…
Browse files Browse the repository at this point in the history
…2488)

* Remove service-accounts component

* Refactor shopping-assistant component

* Add missing header

* Fix typo

* Sync kustomize/base

* Move GSA annotation for shopping assistant in correct component
  • Loading branch information
bourgeoisor committed Apr 17, 2024
1 parent bbc5719 commit 20585fa
Show file tree
Hide file tree
Showing 52 changed files with 345 additions and 626 deletions.
7 changes: 6 additions & 1 deletion kubernetes-manifests/adservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: adservice
spec:
serviceAccountName: default
serviceAccountName: adservice
terminationGracePeriodSeconds: 5
securityContext:
fsGroup: 1000
Expand Down Expand Up @@ -81,3 +81,8 @@ spec:
- name: grpc
port: 9555
targetPort: 9555
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: adservice
76 changes: 75 additions & 1 deletion kubernetes-manifests/cartservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: cartservice
spec:
serviceAccountName: default
serviceAccountName: cartservice
terminationGracePeriodSeconds: 5
securityContext:
fsGroup: 1000
Expand Down Expand Up @@ -80,3 +80,77 @@ spec:
- name: grpc
port: 7070
targetPort: 7070
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: cartservice
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-cart
labels:
app: redis-cart
spec:
selector:
matchLabels:
app: redis-cart
template:
metadata:
labels:
app: redis-cart
spec:
securityContext:
fsGroup: 1000
runAsGroup: 1000
runAsNonRoot: true
runAsUser: 1000
containers:
- name: redis
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: redis:alpine
ports:
- containerPort: 6379
readinessProbe:
periodSeconds: 5
tcpSocket:
port: 6379
livenessProbe:
periodSeconds: 5
tcpSocket:
port: 6379
volumeMounts:
- mountPath: /data
name: redis-data
resources:
limits:
memory: 256Mi
cpu: 125m
requests:
cpu: 70m
memory: 200Mi
volumes:
- name: redis-data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: redis-cart
labels:
app: redis-cart
spec:
type: ClusterIP
selector:
app: redis-cart
ports:
- name: tcp-redis
port: 6379
targetPort: 6379
7 changes: 6 additions & 1 deletion kubernetes-manifests/checkoutservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: checkoutservice
spec:
serviceAccountName: default
serviceAccountName: checkoutservice
securityContext:
fsGroup: 1000
runAsGroup: 1000
Expand Down Expand Up @@ -88,3 +88,8 @@ spec:
- name: grpc
port: 5050
targetPort: 5050
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: checkoutservice
7 changes: 6 additions & 1 deletion kubernetes-manifests/currencyservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: currencyservice
spec:
serviceAccountName: default
serviceAccountName: currencyservice
terminationGracePeriodSeconds: 5
securityContext:
fsGroup: 1000
Expand Down Expand Up @@ -80,3 +80,8 @@ spec:
- name: grpc
port: 7000
targetPort: 7000
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: currencyservice
7 changes: 6 additions & 1 deletion kubernetes-manifests/emailservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: emailservice
spec:
serviceAccountName: default
serviceAccountName: emailservice
terminationGracePeriodSeconds: 5
securityContext:
fsGroup: 1000
Expand Down Expand Up @@ -81,3 +81,8 @@ spec:
- name: grpc
port: 5000
targetPort: 8080
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: emailservice
11 changes: 8 additions & 3 deletions kubernetes-manifests/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
annotations:
sidecar.istio.io/rewriteAppHTTPProbers: "true"
spec:
serviceAccountName: default
serviceAccountName: frontend
securityContext:
fsGroup: 1000
runAsGroup: 1000
Expand Down Expand Up @@ -90,8 +90,8 @@ spec:
value: "0"
# - name: CYMBAL_BRANDING
# value: "true"
- name: ENABLE_ASSISTANT
value: "true"
# - name: ENABLE_ASSISTANT
# value: "true"
# - name: FRONTEND_MESSAGE
# value: "Replace this with a message you want to display on all pages."
# As part of an optional Google Cloud demo, you can run an optional microservice called the "packaging service".
Expand Down Expand Up @@ -134,3 +134,8 @@ spec:
- name: http
port: 80
targetPort: 8080
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: frontend
7 changes: 2 additions & 5 deletions kubernetes-manifests/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ resources:
- paymentservice.yaml
- productcatalogservice.yaml
- recommendationservice.yaml
- shoppingassistantservice.yaml
- redis.yaml
- shippingservice.yaml
components:
# components:
# - ../kustomize/components/cymbal-branding
# - ../kustomize/components/google-cloud-operations
# - ../kustomize/components/memorystore
# - ../kustomize/components/network-policies
# - ../kustomize/components/service-accounts
# - ../kustomize/components/alloydb
# - ../kustomize/components/shopping-assistant
# - ../kustomize/components/spanner
# - ../kustomize/components/container-images-tag
# - ../kustomize/components/container-images-tag-suffix
# - ../kustomize/components/container-images-registry
- ../kustomize/components/disable-shopping-assistant
7 changes: 6 additions & 1 deletion kubernetes-manifests/loadgenerator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
annotations:
sidecar.istio.io/rewriteAppHTTPProbers: "true"
spec:
serviceAccountName: default
serviceAccountName: loadgenerator
terminationGracePeriodSeconds: 5
restartPolicy: Always
securityContext:
Expand Down Expand Up @@ -82,3 +82,8 @@ spec:
limits:
cpu: 500m
memory: 512Mi
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: loadgenerator
7 changes: 6 additions & 1 deletion kubernetes-manifests/paymentservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: paymentservice
spec:
serviceAccountName: default
serviceAccountName: paymentservice
terminationGracePeriodSeconds: 5
securityContext:
fsGroup: 1000
Expand Down Expand Up @@ -79,3 +79,8 @@ spec:
- name: grpc
port: 50051
targetPort: 50051
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: paymentservice
7 changes: 6 additions & 1 deletion kubernetes-manifests/productcatalogservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: productcatalogservice
spec:
serviceAccountName: default
serviceAccountName: productcatalogservice
terminationGracePeriodSeconds: 5
securityContext:
fsGroup: 1000
Expand Down Expand Up @@ -79,3 +79,8 @@ spec:
- name: grpc
port: 3550
targetPort: 3550
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: productcatalogservice
7 changes: 6 additions & 1 deletion kubernetes-manifests/recommendationservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: recommendationservice
spec:
serviceAccountName: default
serviceAccountName: recommendationservice
terminationGracePeriodSeconds: 5
securityContext:
fsGroup: 1000
Expand Down Expand Up @@ -83,3 +83,8 @@ spec:
- name: grpc
port: 8080
targetPort: 8080
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: recommendationservice
82 changes: 0 additions & 82 deletions kubernetes-manifests/redis.yaml

This file was deleted.

7 changes: 6 additions & 1 deletion kubernetes-manifests/shippingservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
labels:
app: shippingservice
spec:
serviceAccountName: default
serviceAccountName: shippingservice
securityContext:
fsGroup: 1000
runAsGroup: 1000
Expand Down Expand Up @@ -79,3 +79,8 @@ spec:
- name: grpc
port: 50051
targetPort: 50051
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: shippingservice
2 changes: 0 additions & 2 deletions kustomize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ Here is the list of the variations available as Kustomize components that you co
These changes directly affect `cartservice`.
- [**Secure with Network Policies**](components/network-policies)
- Deploy fine granular `NetworkPolicies` for Online Boutique.
- [**Create Kubernetes Service Accounts**](components/service-accounts)
- Deploy fine granular `ServiceAccounts` for Online Boutique.
- [**Update the registry name of the container images**](components/container-images-registry)
- [**Update the image tag of the container images**](components/container-images-tag)
- [**Add an image tag suffix to the container images**](components/container-images-tag-suffix)
Expand Down
Loading

0 comments on commit 20585fa

Please sign in to comment.