kubectl proxy open a page with tons of 404s

11/1/2017

I'm new to kubernetes and I'm setting it up on azure.

I've created this script based on what I managed to find in the Azure documentation:

#!/bin/bash

cd "$( dirname "$0" )"

source vars.sh

echo "Create group $KUBE_GROUP"
az group create \
    --verbose \
    --name $KUBE_GROUP \
    --location $LOCATION

echo "Create acs $KUBE_NAME"
az acs create \
    --verbose \
    --name $KUBE_NAME \
    --resource-group $KUBE_GROUP \
    --orchestrator-type Kubernetes \
    --dns-prefix $KUBE_NAME \
    --generate-ssh-key \
    --agent-count 3 > creategroup.log 2>&1

echo "Get credentials for $KUBE_GROUP"
az acs kubernetes get-credentials \
    --verbose \
    --resource-group $KUBE_GROUP \
    --name $KUBE_NAME > getcredentials.log 2>&1

echo "Create registry $REGISTRY_NAME"
az acr create \
    --name $REGISTRY_NAME \
    --resource-group $KUBE_GROUP \
    --location $LOCATION \
    --admin-enabled true \
    --sku Basic > create_registry.log

echo "Setup kubernetes environment"
ssh-keygen -f "${HOME}/.ssh/known_hosts" -R "${KUBE_NAME}mgmt.westeurope.cloudapp.azure.com"
scp azureuser@${KUBE_NAME}mgmt.westeurope.cloudapp.azure.com:.kube/config $HOME/.kube/config

kubectl config current-context

#echo "Create a single nginx instance in kubernetes"
#kubectl run namenginx1 --image=nginx

REGISTRY_PASSWORD=$( az acr credential show \
    --name $REGISTRY_NAME \
    --resource-group $KUBE_GROUP \
    | jq '.passwords[0] .value' \
    | sed 's/"//g' )

echo "Create secret docker-registry"
kubectl create secret docker-registry kuberegistry \
    --docker-server $REGISTRY_URL \
    --docker-username $REGISTRY_NAME \
    --docker-password $REGISTRY_PASSWORD \
    --docker-email $REGISTRY_EMAIL > kuberegistry.log 2>&1

nohup kubectl proxy &
firefox 'http://localhost:8001/ui/'

Now, I'd expect to see the kubernetes dashboard where I can do a lot of things. But it seems this is not the case. If I open the FF console, I see tons of 404s and the page remains blank.

Does anybody see the reason why it's not working? Or give me any suggestions on how to solve the issue?

Thanks


I've tried to execute az acs kubernetes browse -g $KUBE_GROUP -n $KUBE_NAME but I'm getting this error:

'proxycommand'
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/application.py", line 212, in execute
    result = expanded_arg.func(params)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 620, in _execute_command
    reraise(*sys.exc_info())
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 602, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 154, in k8s_browse
    _k8s_browse_internal(name, acs_info, disable_browser, ssh_key_file)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 164, in _k8s_browse_internal
    _k8s_get_credentials_internal(name, acs_info, browse_path, ssh_key_file)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/custom.py", line 835, in _k8s_get_credentials_internal
    '.kube/config', path_candidate, key_filename=ssh_key_file)
  File "/usr/local/Cellar/azure-cli/2.0.19/libexec/lib/python3.6/site-packages/azure/cli/command_modules/acs/acs_client.py", line 65, in secure_copy
    proxy = paramiko.ProxyCommand(host_config['proxycommand'])
KeyError: 'proxycommand'

NOTE: I've made sure that the kubectl proxy was not running and that the port was not 'busy'.

-- Stefano
azure
kubernetes

1 Answer

11/2/2017

I test your script in my lab, there is a mistake in your script.

{KUBE_NAME}mgmt.westeurope.cloudapp.azure.com it should be {KUBE_NAME}.westeurope.cloudapp.azure.com. No need mgmt.

If you want to connect to the web UI, you need running

az acs kubernetes get-credentials --resource-group=$KUBE_GROUP --name=$KUBE_NAME    
nohup az acs kubernetes browse -g $KUBE_GROUP -n $KUBE_NAME &

More information about this please refer to this link.

Update:

You need check .kube/config file, if possible, you could recreate it.

The issue is because browser cache. Clean up the cache in the browser will solve this issue.


External Update:

Beside the cache, when the command opens the page on your browser, it'll go directly to http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy. There's a missing / in the end. It should be http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/

-- Shui shengbao
Source: StackOverflow