Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yamls of homework #14

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions homework/ymh-webapp/backend-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.10

WORKDIR /app

COPY . /app

RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
EXPOSE 8000

ENV DATABASE_URL="postgresql://postgres:postgresmaster@ymh-postgresql-0/test"

CMD ["sh", "-c", "cd backend && uvicorn main:app --proxy-headers --host 0.0.0.0 --port 8000"]

25 changes: 25 additions & 0 deletions homework/ymh-webapp/backend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ymh-backend
namespace: ymh-webapp
spec:
replicas: 1
template:
metadata:
labels:
app: ymh-backend
spec:
initContainers:
- name: ymh-initcontainer
image: ymh636/ymh-backend
command: ['sh', '-c', 'alembic upgrade head && python3 addUser.py']
containers:
- name: ymh-backend
image: ymh636/ymh-backend
ports:
- containerPort: 8000
selector:
matchLabels:
app: ymh-backend

15 changes: 15 additions & 0 deletions homework/ymh-webapp/backend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: ymh-backend
namespace: ymh-webapp
spec:
selector:
app: ymh-backend
type: NodePort
ports:
- protocol: TCP
port: 8000
targetPort: 8000
nodePort: 31426

13 changes: 13 additions & 0 deletions homework/ymh-webapp/frontend-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:14

WORKDIR /app

COPY . /app

RUN npm install
RUN npm install -D tailwindcss


EXPOSE 3000

CMD ["npm", "run", "start"]
20 changes: 20 additions & 0 deletions homework/ymh-webapp/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ymh-frontend
namespace: ymh-webapp
spec:
replicas: 1
template:
metadata:
labels:
app: ymh-frontend
spec:
containers:
- name: ymh-frontend
image: ymh636/ymh-frontend
ports:
- containerPort: 3000
selector:
matchLabels:
app: ymh-frontend
14 changes: 14 additions & 0 deletions homework/ymh-webapp/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: ymh-frontend
namespace: ymh-webapp
spec:
selector:
app: ymh-frontend
type: NodePort
ports:
- protocol: TCP
port: 3000
targetPort: 3000
nodePort: 31425
37 changes: 37 additions & 0 deletions homework/ymh-webapp/helm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Helm 裝 Postgres 我的作法

1. 在本地端裝postgres

```Shell
helm install ymh-postgresql-0 bitnami/postgresql --namespace ymh-webapp --set global.postgresql.auth.postgresPassword=postgresmaster --set global.postgresql.auth.password=postgresmaster --set global.postgresql.auth.username=postgres --set global.postgresql.auth.database=test
```

下面這兩個指令是要試連用的
```Shell
export POSTGRES_PASSWORD=$(kubectl get secret --namespace ymh-webapp ymh-postgres-postgresql -o jsonpath="{.data.postgres-password}" | base64 -d)
```

```Shell
kubectl run ymh-postgres-postgresql-client --rm --tty -i --restart='Never' --namespace ymh-webapp --image docker.io/bitnami/postgresql:16.1.0-debian-11-r9 --env="PGPASSWORD=$POSTGRES_PASSWORD" \
--command -- psql --host ymh-postgres-postgresql -U postgres -d test -p 5432
```

2. 把本地端的檔案導出

```Shell
helm get values <release-name> > values.yaml
```

3. 確認檔案是對的、並且接上遠端的kubeconfig,然後刪除本地端的

```Shell
export KUBECONFIG=/Users/huangyoumei/poetry-demo/kubeconfig.yaml
helm uninstall <release-name>
```
4. 部署到遠端

```Shell
helm install <release-name> -f values.yaml <chart-name>
```


Loading