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

Serve robots.txt for Prow #4365

Merged
merged 11 commits into from
Nov 15, 2021
8 changes: 6 additions & 2 deletions prow/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ This folder contains files related to the configuration of the Prow production c
The structure of the folder looks as follows:

```
├── components # Definitions of Prow components and cluster configuration.
└── resources # Helm charts used by the Prow cluster.
├── components # Definitions of Prow components and cluster configuration.
├── resources # Helm charts used by the Prow cluster.
└── static-files # Files that will be uploaded to the nginx web server.
```

### Adding static files
All files added to the `static-files` folder are automatically uploaded by the Prow `config_updater` plugin to the cluster in a ConfigMap. Uploaded files are mounted by the web server in the web root directory. To route traffic for a specific path to the NGINX web server, in order to serve these files, update the Ingress `tls-ing` configuration in `tls-ing_ingress.yaml`.
4 changes: 4 additions & 0 deletions prow/cluster/components/tls-ing_ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ spec:
backend:
serviceName: pushgateway-external
servicePort: 80
- path: /robots.txt
backend:
serviceName: web-server
servicePort: 80
82 changes: 82 additions & 0 deletions prow/cluster/components/web-server_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-server
namespace: default
labels:
app: web-server
spec:
selector:
matchLabels:
app: web-server
template:
metadata:
labels:
app: web-server
spec:
containers:
- name: nginx
image: nginx:1.20-alpine
ports:
- containerPort: 80
volumeMounts:
- name: config
mountPath: /etc/nginx/conf.d/
- name: static-files
mountPath: /usr/share/nginx/html/
livenessProbe:
httpGet:
path: /robots.txt
port: 80
initialDelaySeconds: 10
periodSeconds: 3
timeoutSeconds: 30
readinessProbe:
httpGet:
path: /robots.txt
port: 80
initialDelaySeconds: 10
periodSeconds: 3
timeoutSeconds: 30
volumes:
- name: config
configMap:
name: web-server-config
- name: static-files
configMap:
name: static-files
---
apiVersion: v1
kind: ConfigMap
metadata:
name: web-server-config
namespace: default
data:
default.conf: |
server {
listen 80;
server_name _;

location / {
root /usr/share/nginx/html/;
}

location = /50x.html {
root /usr/share/nginx/html;
}
}
---
apiVersion: v1
kind: Service
metadata:
name: web-server
namespace: default
labels:
app: web-server
spec:
type: NodePort
selector:
app: web-server
ports:
- name: http
port: 80
1 change: 1 addition & 0 deletions prow/cluster/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ prow_components=(
"tide_deployment.yaml"
"tide_service.yaml"
"tls-ing_ingress.yaml"
"web_server_deployment.yaml"
)

function ensure-context() {
Expand Down
2 changes: 2 additions & 0 deletions prow/cluster/static-files/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
2 changes: 2 additions & 0 deletions prow/plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ config_updater:
clusters:
trusted-workload:
- default
prow/cluster/static-files/*:
name: static-files

triggers:
- repos:
Expand Down