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

chore: nexus3 tilt setup #127

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
fix: update nexus setup scripts, nginx config, portforwards
  • Loading branch information
soniqua committed Aug 22, 2024
commit c149241ee37848c513bf5ce2ff3a07c6234c9911
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -47,3 +47,6 @@ bitbucket.crt

# Helm Unittest Debug
charts/snyk-broker/.debug

# Tiltfile local resources
tilt/nexus-cr/admin.txt
37 changes: 18 additions & 19 deletions tilt/nexus-cr/Tiltfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
allow_k8s_contexts('docker-desktop')
load('ext://execute_in_pod', 'execute_in_pod')
load('ext://helm_resource', 'helm_resource', 'helm_repo')
load('ext://uibutton', 'cmd_button', 'text_input', 'location')
## Add the Bitnami Helm Repo
helm_repo('bitnami','https://charts.bitnami.com/bitnami')
# Set up a PVC for Nexus
@@ -23,24 +22,24 @@ helm_resource(
],
port_forwards=[8443, 8080]
)
k8s_resource(workload='nexus3',port_forwards=8083)
local_resource(
name="nexus3 password reset",
cmd="./nexusPassword.sh",
resource_deps=[
'nexus3',
'nginx'
],
labels=['nexus3'],
)
local_resource(
name="nexus3 setup",
cmd="./nexusSetup.sh",
resource_deps=[
"nexus3 password reset"
],
labels=['nexus3']
)
if config.tilt_subcommand == 'up':
local_resource(
name="nexus3 password reset",
cmd="./nexusPassword.sh",
resource_deps=[
'nexus3',
'nginx'
],
labels=['nexus3'],
)
local_resource(
name="nexus3 setup",
cmd="./nexusSetup.sh",
resource_deps=[
"nexus3 password reset"
],
labels=['nexus3']
)
# At this point you'll need to:
# 1. add kubernetes.docker.internal to your insecure docker registries
# 2. docker login kubernetes.docker.internal admin:admin123
22 changes: 11 additions & 11 deletions tilt/nexus-cr/nexusPassword.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

set -x
## Get the nexus3 admin password and write to disk
if ! [ -f "admin.txt" ]; then
ADMIN_PASSWORD=$(kubectl exec "$(tilt get kd nexus3 -ojsonpath='{.status.pods[0].name}')" -- cat /nexus-data/admin.password)
echo "$ADMIN_PASSWORD" > admin.txt
# Change the initial password to admin123
curl -ifu "admin:$ADMIN_PASSWORD" \
-X PUT \
-H 'Content-Type: text/plain' \
--data "admin123" \
http://localhost:80/service/rest/v1/security/users/admin/change-password
fi
ADMIN_PASSWORD=$(kubectl exec "$(tilt get kd nexus3 -ojsonpath='{.status.pods[0].name}')" -- cat /nexus-data/admin.password)
echo "$ADMIN_PASSWORD" > admin.txt
# Change the initial password to admin123
curl -ifu "admin:$ADMIN_PASSWORD" \
--fail \
-k \
-X PUT \
-H 'Content-Type: text/plain' \
--data "admin123" \
https://localhost:8443/service/rest/v1/security/users/admin/change-password
8 changes: 6 additions & 2 deletions tilt/nexus-cr/nexusSetup.sh
Original file line number Diff line number Diff line change
@@ -7,10 +7,12 @@ fi

## Anonymous Access
curl -X PUT \
'http://localhost/service/rest/v1/security/anonymous' \
'https://localhost:8443/service/rest/v1/security/anonymous' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-u admin:admin123 \
-k \
--fail-with-body \
-d '{
"enabled": true,
"userId": "admin",
@@ -19,9 +21,11 @@ curl -X PUT \

# Create a docker repo
curl -X POST \
http://localhost:80/service/rest/v1/repositories/docker/hosted \
https://localhost:8443/service/rest/v1/repositories/docker/hosted \
-H "Content-Type: application/json" \
-k \
-u admin:admin123 \
--fail-with-body \
-d '{
"name": "docker",
"online": true,
20 changes: 2 additions & 18 deletions tilt/nexus-cr/nginx/values.yaml
Original file line number Diff line number Diff line change
@@ -35,29 +35,13 @@ serverBlock: |-
}

server {
listen 8080;
listen 8081;
resolver 10.96.0.10 valid=10s;
server_name nginx

ssl off;

# Docker /v2 and /v1 (for search) requests
location /v2 {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "http";
proxy_pass http://nexus3.default.svc.cluster.local:8081/repository/docker/$request_uri;
}
location /v1 {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "http";
proxy_pass http://nexus3.default.svc.cluster.local:8081/repository/docker/$request_uri;
}

# Regular Nexus requests
# Simulates a Docker registry exposed on port 8081
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
Loading