Skip to content

Commit

Permalink
commit 29
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawnSPG committed Dec 17, 2023
1 parent 5624787 commit 6ce0d36
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
11 changes: 11 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ dev-up-local:
kubectl wait --timeout=120s --namespace=local-path-storage --for=condition=Available deployment/local-path-provisioner

kind load docker-image $(TELEPRESENCE) --name $(KIND_CLUSTER)
kind load docker-image $(POSTGRES) --name $(KIND_CLUSTER)


# step 2
# if need password is @SHxx2014030104
Expand All @@ -161,6 +163,9 @@ dev-restart:
kubectl rollout restart deployment $(APP) --namespace=$(NAMESPACE)

dev-apply:
kustomize build zarf/k8s/dev/database | kubectl apply -f -
kubectl rollout status --namespace=$(NAMESPACE) --watch --timeout=120s sts/database

kustomize build zarf/k8s/dev/sales | kubectl apply -f -
kubectl wait pods --namespace=$(NAMESPACE) --selector app=$(APP) --for=condition=Ready

Expand Down Expand Up @@ -232,3 +237,9 @@ readiness-local:

readiness:
curl -il http://$(SERVICE_NAME).$(NAMESPACE).svc.cluster.local:4000/debug/readiness

pgcli-local:
pgcli postgresql://postgres:postgres@localhost

pgcli:
pgcli postgresql://postgres:postgres@database-service.$(NAMESPACE).svc.cluster.local
92 changes: 92 additions & 0 deletions zarf/k8s/dev/database/dev-database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: v1
kind: Namespace
metadata:
name: sales-system
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: database-data
namespace: sales-system
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: database
namespace: sales-system
spec:
selector:
matchLabels:
app: database
replicas: 1
template:
metadata:
labels:
app: database
spec:
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
terminationGracePeriodSeconds: 60
volumes:
- name: data
persistentVolumeClaim:
claimName: database-data
containers:
- name: postgres
image: postgres:15.3
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
resources:
requests:
cpu: "500m" # I need access to 1/2 core on the node.
memory: 500Mi
limits:
cpu: "500m" # Execute instructions 50ms/100ms on my 1/2 core.
memory: 500Mi
env:
- name: POSTGRES_PASSWORD
value: postgres
ports:
- name: postgres
containerPort: 5432
livenessProbe:
exec:
command:
- pg_isready
- -h
- localhost
- -U
- postgres
initialDelaySeconds: 30
timeoutSeconds: 5
readinessProbe:
exec:
command:
- pg_isready
- -h
- localhost
- -U
- postgres
initialDelaySeconds: 5
timeoutSeconds: 1
---
apiVersion: v1
kind: Service
metadata:
name: database-service
namespace: sales-system
spec:
type: ClusterIP
selector:
app: database
ports:
- name: postgres
port: 5432
targetPort: postgres
4 changes: 4 additions & 0 deletions zarf/k8s/dev/database/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./dev-database.yaml

0 comments on commit 6ce0d36

Please sign in to comment.