harbor-helm icon indicating copy to clipboard operation
harbor-helm copied to clipboard

Basic headless operation how-to?

Open brianthelion opened this issue 3 years ago • 3 comments

Goal

My goal is to minimize the chart deployment footprint while still being able to administer Harbor without the web UI.

Here's a simple script that exhibits my intent using kind. It is not working as expected.

What I tried

set -ex
KIND=$(which kind)
HELM=$(which helm)
CLUSTER=harbor-test
TMP=$(mktemp)
PORT=31443

cat > ${TMP} <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 30003 # <---- from chart docs
    hostPort: ${PORT}
EOF

${KIND} create cluster \
        --name ${CLUSTER} \
        --config ${TMP}

${HELM} repo add harbor https://helm.goharbor.io
${HELM} install my-release harbor/harbor \
        --set expose.type=nodePort \
        --set expose.tls.auto.commonName=foo \
        --debug \
        --wait

curl -k "https://localhost:${PORT}"

curl -k "https://localhost:${PORT}/api"

What happened

...
+ curl -k https://localhost:31443/api
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

brianthelion avatar Nov 29 '21 14:11 brianthelion

Further exploration. I'm documenting this in case others land here looking for solutions.

Succeeds

$ curl -k "https://localhost:${PORT}/api/v2.0/ping"
Pong

Fails

$ curl -k "https://localhost:${PORT}/api/v2.0/swagger.yaml"
{"errors":[{"code":"NOT_FOUND","message":"path /api/v2.0/swagger.yaml was not found"}]}

brianthelion avatar Nov 29 '21 15:11 brianthelion

Robot

Fails

curl -k "https://localhost:${PORT}/api/v2.0/robots" \
     -u "admin:Harbor12345" \
     -X POST \
     -H "Content-Type: application/json" \
     -d '{"name":"test1", "duration":30, "description":"test", "disable":false, "level":"system",
          "permissions":[{"kind":"system", "namespace":"/", "access":[{"resource":"project", "action":"create"}]}]
         }' > file.json

username=$(cat file.json | jq -r .name)
password=$(cat file.json | jq -r .secret)
echo "$password" | docker login https://localhost:${PORT}/ --username "$username" --password-stdin
Error response from daemon: Get https://localhost:31443/v2/: Get https://core.harbor.domain/service/token?account=robot%24test1&client_id=docker&offline_token=true&service=harbor-registry: dial tcp: lookup core.harbor.domain: no such host

brianthelion avatar Nov 29 '21 16:11 brianthelion

maybe your values.yaml, such as extenalURL, is not configured correctly

zyyw avatar Jan 13 '22 08:01 zyyw

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

github-actions[bot] avatar Feb 08 '24 09:02 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. If this issue is still relevant, please re-open a new issue.

github-actions[bot] avatar Mar 11 '24 09:03 github-actions[bot]