Skip to content

Commit

Permalink
fix(docs): cherry-pick updates to docs structure and routing from v2
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed May 13, 2024
1 parent c6e39bf commit ec59b2e
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 150 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/_docs_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jobs:
else
cat >> "$GITHUB_ENV" <<EOF
WERF_RELEASE=werfio-documentation-${{ inputs.env }}
WERF_SET_GITHUB_REF=global.github_ref=v1.2.3-dev
WERF_SET_GITHUB_REF=global.github_ref=main
EOF
fi
- name: Deploy
uses: werf/actions/converge@v1.2
uses: werf/actions/converge@v2
with:
env: ${{ inputs.env }}
kube-config-base64-data: ${{ secrets.kubeConfig }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/docs_deploy_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
deploy-test:
uses: ./.github/workflows/_docs_deploy.yml
with:
persistent: true
env: test
secrets:
kubeConfig: ${{ secrets.KUBECONFIG_BASE64_DEV }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/docs_deploy_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
deploy-test:
uses: ./.github/workflows/_docs_deploy.yml
with:
persistent: true
env: test
secrets:
kubeConfig: ${{ secrets.KUBECONFIG_BASE64_DEV }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_trdl-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
fetch-depth: 0

- name: Converge
uses: werf/actions/converge@v1.2
uses: werf/actions/converge@v2
with:
env: production
kube-config-base64-data: ${{ secrets.KUBECONFIG_BASE64_PROD }}
Expand All @@ -62,7 +62,7 @@ jobs:
fetch-depth: 0

- name: Install werf
uses: werf/actions/install@v1.2
uses: werf/actions/install@v2
with:
channel: alpha

Expand Down
4 changes: 2 additions & 2 deletions Taskfile.dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ tasks:
# Run compose up in docs directory.
cd docs
which werf >/dev/null || source $(trdl use werf 1.2 beta)
which werf >/dev/null || source $(trdl use werf 2 beta)
werf compose up jekyll_base --dev --docker-compose-command-options="$services" --platform=linux/amd64 || true
compose:up:standalone:
Expand All @@ -589,7 +589,7 @@ tasks:
cmds:
- |
cd docs
which werf >/dev/null || source $(trdl use werf 1.2 beta)
which werf >/dev/null || source $(trdl use werf 2 beta)
# Workaround: set image variable to stub image.
WERF_JEKYLL_BASE_DOCKER_IMAGE_NAME=nginx:latest \
werf compose down
2 changes: 1 addition & 1 deletion cmd/werf/docs/md_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func replaceLinks(s string) string {
links := xurls.Relaxed.FindAllString(s, -1)
for _, link := range links {
linkText := link
for _, prefix := range []string{"werf.io/documentation", "https://werf.io/documentation"} {
for _, prefix := range []string{"werf.io/docs", "https://werf.io/docs"} {
if strings.HasPrefix(link, prefix) {
link = strings.TrimPrefix(link, prefix)
link = fmt.Sprintf("{{ \"%s\" | true_relative_url }}", link)
Expand Down
40 changes: 24 additions & 16 deletions docs/.helm/templates/10-app.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
{{- $_ := set . "Version" ( splitList "/" .Values.global.github_ref | last ) }}
{{- $_ := set . "VersionURLNormalized" ( printf "%s" .Version | lower | replace "+" "-plus-" | replace "_" "-u-" ) }}
{{- $_ := set . "VersionDNSNormalized" ( printf "%s" .Version | lower | replace "+" "-plus-" | replace "_" "-u-" | replace "." "-dot-" ) }}
{{- $refs := list $.Values.global.github_ref }}
{{- if eq $.Values.werf.env "test" }}
{{- $refs = concat $refs (list "v2.0.3" "v1.2.294+fix1") }}
{{- end }}

{{- range $_, $ref := $refs }}

{{- $version := splitList "/" $ref | last }}
{{- $versionDNSNormalized := printf "%s" $version | lower | replace "+" "-plus-" | replace "_" "-u-" | replace "." "-dot-" }}

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
annotations:
"werf.io/replicas-on-creation": "1"
labels:
service: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
service: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
spec:
minReadySeconds: 5
revisionHistoryLimit: 5
selector:
matchLabels:
service: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
service: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
template:
metadata:
labels:
service: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
service: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
spec:
imagePullSecrets:
- name: github-werfio
priorityClassName: {{ pluck .Values.werf.env .Values.priorityClassName | first | default .Values.priorityClassName._default }}
priorityClassName: {{ pluck $.Values.werf.env $.Values.priorityClassName | first | default $.Values.priorityClassName._default }}
containers:
- name: web
command: ["nginx", "-g", "daemon off;"]
image: {{ index .Values.werf.image "web" }}
{{- include "resources" . | indent 10 }}
image: {{ index $.Values.werf.image "web" }}
{{- include "resources" $ | indent 10 }}
ports:
- containerPort: 80
name: http
Expand All @@ -48,11 +55,11 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
spec:
clusterIP: None
selector:
service: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
service: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
ports:
- name: http
port: 80
Expand All @@ -61,21 +68,22 @@ spec:
apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
updatePolicy:
updateMode: "Initial"
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
spec:
maxUnavailable: 1
selector:
matchLabels:
service: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
service: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
{{- end }}
110 changes: 40 additions & 70 deletions docs/.helm/templates/20-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,82 +1,38 @@
{{- $_ := set . "Version" ( splitList "/" .Values.global.github_ref | last ) }}
{{- if eq .Version "main" }}
{{- $_ := set . "VersionURLNormalized" "latest" }}
{{- else }}
{{- $_ := set . "VersionURLNormalized" ( printf "%s" .Version | lower | replace "+" "-plus-" | replace "_" "-u-" ) }}
{{- end }}
{{- $_ := set . "VersionDNSNormalized" ( printf "%s" .Version | lower | replace "+" "-plus-" | replace "_" "-u-" | replace "." "-dot-" ) }}
{{- $host := pluck .Values.werf.env .Values.host | first | default .Values.host._default }}
{{- if hasPrefix "review" .Values.werf.env }}
{{- $host = ( printf "%s.%s" .Values.werf.env (pluck "dev" .Values.host | first | default .Values.host._default ) | lower ) }}
{{- $refs := list $.Values.global.github_ref }}
{{- if eq $.Values.werf.env "test" }}
{{- $refs = concat $refs (list "v2.0.3" "v1.2.294+fix1") }}
{{- end }}

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}-configurator
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /documentation/{{ .VersionURLNormalized }}/configurator.html
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header X-Original-URI $request_uri;
set $configurator_selected_page $1;
{{- range $_, $ref := $refs }}

ssi on;
ssi_silent_errors on;
{{- $version := splitList "/" $ref | last }}
{{- $versionDNSNormalized := printf "%s" $version | lower | replace "+" "-plus-" | replace "_" "-u-" | replace "." "-dot-" }}

{{ include "rewrites" . | indent 6 }}
{{- if eq .Values.werf.env "production" }}
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
{{- $versionURLNormalized := "" }}
{{- if eq $version "main" }}
{{- $versionURLNormalized = "latest" }}
{{- else }}
nginx.ingress.kubernetes.io/auth-url: http://basic-auth.kube-basic-auth.svc.cluster.local/werfio
{{- $versionURLNormalized = printf "%s" $version | lower | replace "+" "-plus-" | replace "_" "-u-" }}
{{- end }}
spec:
tls:
- hosts:
- {{ $host }}
- ru.{{ $host }}
{{- if eq .Values.werf.env "production" }}
- www.{{ $host }}

{{- $host := pluck $.Values.werf.env $.Values.host | first | default $.Values.host._default }}
{{- if hasPrefix "review" $.Values.werf.env }}
{{- $host = printf "%s.%s" $.Values.werf.env (pluck "dev" $.Values.host | first | default $.Values.host._default ) | lower }}
{{- end }}
secretName: tls-{{ $host }}
rules:
- host: {{ $host }}
http:
paths:
- path: /documentation/{{ .VersionURLNormalized }}/configurator(?:/(.*))?$
pathType: Prefix
backend:
service:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
port:
name: http
- host: ru.{{ $host }}
http:
paths:
- path: /documentation/{{ .VersionURLNormalized }}/configurator(?:/(.*))?$
pathType: Prefix
backend:
service:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
port:
name: http

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header X-Original-URI $request_uri;
ssi on;
ssi_silent_errors on;
{{ include "rewrites" . | indent 6 }}
{{- if eq .Values.werf.env "production" }}
{{ include "rewrites" $ | indent 6 }}
{{- if eq $.Values.werf.env "production" }}
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
{{- else }}
nginx.ingress.kubernetes.io/auth-url: http://basic-auth.kube-basic-auth.svc.cluster.local/werfio
Expand All @@ -86,29 +42,43 @@ spec:
- hosts:
- {{ $host }}
- ru.{{ $host }}
{{- if eq .Values.werf.env "production" }}
{{- if eq $.Values.werf.env "production" }}
- www.{{ $host }}
{{- end }}
secretName: tls-{{ $host }}
rules:
- host: {{ $host }}
http:
paths:
- path: /documentation/{{ .VersionURLNormalized }}
pathType: Prefix
- path: /docs/{{ $versionURLNormalized }}/
pathType: ImplementationSpecific
backend:
service:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
port:
name: http
- path: /documentation/{{ $versionURLNormalized }}/
pathType: ImplementationSpecific
backend:
service:
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
port:
name: http
- host: ru.{{ $host }}
http:
paths:
- path: /documentation/{{ .VersionURLNormalized }}
pathType: Prefix
- path: /docs/{{ $versionURLNormalized }}/
pathType: ImplementationSpecific
backend:
service:
name: {{ .Chart.Name }}-{{ .VersionDNSNormalized }}
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
port:
name: http
---
- path: /documentation/{{ $versionURLNormalized }}/
pathType: ImplementationSpecific
backend:
service:
name: {{ $.Chart.Name }}-{{ $versionDNSNormalized }}
port:
name: http
{{- end }}

0 comments on commit ec59b2e

Please sign in to comment.