-
Notifications
You must be signed in to change notification settings - Fork 244
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
Install and use a reverse proxy for staging devfile registry #5922
Merged
openshift-merge-robot
merged 8 commits into
redhat-developer:main
from
feloy:feature-5920/devfile-proxy-for-tests
Jul 20, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6d44e48
Kubernetes Manifests to deploy nginx reverse proxy for staging devfil…
feloy be5a3f8
Get the external address of the loadBalancer service for devfile proxy
feloy 6dc5d59
If DEVFILE_PROXY is defined, use it as Devfile registry
feloy 99854eb
Fix get address from Windows
feloy 1faa7dd
Add some log displaying proxy address found
feloy fd28ec3
Filter requests on user agent
feloy b34dc75
Add Go-http-client user-agent
feloy 3ce7f79
Add doc
feloy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: devfile-proxy | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx | ||
namespace: devfile-proxy | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 8080 | ||
volumeMounts: | ||
- mountPath: /etc/nginx # mount nginx-conf volumn to /etc/nginx | ||
readOnly: true | ||
name: nginx-conf | ||
- mountPath: /var/log/nginx | ||
name: log | ||
- mountPath: /var/cache/nginx | ||
name: cache | ||
- mountPath: /var/run | ||
name: run | ||
- mountPath: /data/nginx/cache | ||
name: nginx-cache | ||
resources: | ||
requests: | ||
memory: 256Mi | ||
cpu: 256m | ||
limits: | ||
memory: 256Mi | ||
cpu: 256m | ||
volumes: | ||
- name: nginx-conf | ||
configMap: | ||
name: nginx-conf # place ConfigMap `nginx-conf` on /etc/nginx | ||
items: | ||
- key: nginx.conf | ||
path: nginx.conf | ||
- name: log | ||
emptyDir: {} | ||
- name: cache | ||
emptyDir: {} | ||
- name: run | ||
emptyDir: {} | ||
- name: nginx-cache | ||
emptyDir: {} | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx | ||
namespace: devfile-proxy | ||
spec: | ||
type: LoadBalancer | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
selector: | ||
app: nginx | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: nginx-conf | ||
namespace: devfile-proxy | ||
data: | ||
nginx.conf: | | ||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
proxy_cache_path | ||
/data/nginx/cache | ||
levels=1:2 | ||
keys_zone=app:1M | ||
max_size=100M; | ||
|
||
log_format cacheStatus '$host $server_name $server_port $remote_addr $upstream_cache_status $remote_user [$time_local] " $request " ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
# Need to have a DNS server to resolve the FQDNs provided to proxy_pass | ||
# Use the DNS resolver provided to the container | ||
resolver 172.21.0.10; | ||
|
||
map "$http_user_agent" $proxybackend { | ||
default ""; | ||
"~^containerd" https://registry.stage.devfile.io; | ||
"~^Go-http-client" https://registry.stage.devfile.io; | ||
} | ||
|
||
server { | ||
listen 8080; | ||
|
||
error_log /dev/stderr error; | ||
access_log /dev/stdout cacheStatus; | ||
|
||
location / { | ||
proxy_cache app; | ||
proxy_pass $proxybackend; | ||
proxy_set_header Host registry.stage.devfile.io; | ||
proxy_ignore_headers Set-Cookie; | ||
proxy_ignore_headers Cache-Control; | ||
proxy_cache_valid any 30m; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, where did you retrieve this IP address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the resolver set for the containers (in /etc/resolv.conf) in the IBM Cloud Kubernetes clusters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay - thanks.
/lgtm
I'll let the others (@anandrkskd ) take another look to approve it.