Skip to content

Commit

Permalink
chore: verify nginx ingress (#49)
Browse files Browse the repository at this point in the history
* chore: verfiy nginx ingress

* docs: update on local dev
  • Loading branch information
agrrh authored Aug 25, 2024
1 parent 3c56e10 commit 49eae37
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ Refer to wiki for [Quickstart](https://github.com/agrrh/pagetron/wiki#quickstart

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Local Development

Recommended way is to use following tools:

1. [minikube](https://minikube.sigs.k8s.io/docs/) to provide local kubernetes cluster

```shell
minikube start
minikube addons enable ingress
```

2. [skaffold](https://skaffold.dev) to run local code in cluster with efficient feedback loop

```shell
${EDITOR} charts/pagetron/values.dev.yaml
skaffold dev
```

3. Simply visit `publicUrl`.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Roadmap

- [x] [Prototype Stage](https://github.com/agrrh/pagetron/milestone/1)
Expand Down
25 changes: 20 additions & 5 deletions charts/pagetron/templates/common.ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,49 @@ metadata:
component: common
annotations:
{{- if eq $.Values.ingressClass "nginx" }}
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
{{- else if eq $.Values.ingressClass "traefik" }}
traefik.ingress.kubernetes.io/router.middlewares: {{ $.Release.Namespace }}-backend-strip-prefix@kubernetescrd
traefik.ingress.kubernetes.io/router.middlewares: "{{ $.Release.Namespace }}-backend-strip-prefix@kubernetescrd"
{{- end }}

spec:
ingressClassName: {{ $.Values.ingressClass }}
rules:
- host: {{ $.Values.publicUrl | trimPrefix "https://" | trimPrefix "http://" | quote }}
http:
paths:
{{- if eq $.Values.ingressClass "nginx" }}
- path: /api/(.*)
pathType: ImplementationSpecific
backend:
service:
name: pagetron-backend
port:
number: 80
- path: /(.*)
pathType: ImplementationSpecific
backend:
service:
name: pagetron-frontend
port:
number: 80
{{- else if eq $.Values.ingressClass "traefik" }}
- path: /
pathType: Prefix
backend:
service:
name: pagetron-frontend
port:
number: 80
{{- if eq $.Values.ingressClass "nginx" }}
- path: /api/(.+)
{{- else if eq $.Values.ingressClass "traefik" }}
- path: /api
{{- end }}
pathType: Prefix
backend:
service:
name: pagetron-backend
port:
number: 80
{{- end }}

{{- if eq $.Values.ingressClass "traefik" }}
---
Expand Down
7 changes: 5 additions & 2 deletions charts/pagetron/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ targets:
- https://fastapi.tiangolo.com
- https://prometheus.io

publicUrl: "https://pagetron-dev.agrrh.com"

# May be a good idea to use nip.io and minikube, e.g.:
# publicUrl: http://pagetron.192-168-42-1.nip.io
# (know your minikube address with `minikube ip` command)
# ingressClass: nginx
publicUrl: https://pagetron-dev.agrrh.com
ingressClass: traefik

timezone: Europe/Moscow
Expand Down

0 comments on commit 49eae37

Please sign in to comment.