2

我有这种情况:

  • 运行 Docker 容器的运行 Debian 的主机。
  • 一个安装了CodeReady Containers (CRC)的 CentOS docker 容器。CRC 通过命令行在容器上工作,没有问题。

我想从主机访问(在容器文件中的https://console-openshift-console.apps-crc.testing特定 IP 上)工作的 CRC Web 控制台。hosts


我找到了远程访问 CRC 的这个 RedHat 指南

并且,应用于 Docker 容器,对以下内容进行更改haproxy.conf

global
log 127.0.0.1 local0
debug

defaults
log global
mode http
timeout connect 5000
timeout check 5000
timeout client 30000
timeout server 30000

frontend apps
bind CONTAINER_IP:80
bind CONTAINER_IP:443
option tcplog
mode tcp
default_backend apps

backend apps
mode tcp
balance roundrobin
option ssl-hello-chk
server webserver1 CRC_IP:6443 check

frontend api
bind CONTAINER_IP:6443
option tcplog
mode tcp
default_backend api

backend api
mode tcp
balance roundrobin
option ssl-hello-chk
server webserver1 CRC_IP:6443 check

为容器启用转发:

$ sysctl net.ipv4.conf.all.forwarding=1
$ sudo iptables -P FORWARD ACCEPT

并且还在代理后面启动 CRC

$ crc config set http-proxy http://example.proxy.com:<port>
$ crc config set https-proxy http://example.proxy.com:<port>
$ crc config set no-proxy <comma-separated-no-proxy-entries>

https://console-openshift-console.apps-crc.testing我可以成功地从主机调用 url (正确配置了dnsmasq 作为 DNS 解析器)!!!

但我收到此错误:

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {
    
  },
  "status": "Failure",
  "message": "forbidden: User \"system:anonymous\" cannot get path \"/\"",
  "reason": "Forbidden",
  "details": {
    
  },
  "code": 403
}

笔记:

  1. 当 CRC 开始时,我有一个警告:WARN Wildcard DNS resolution for apps-crc.testing does not appear to be working

  2. 即使尝试oc通过命令行在主机机器上使用 登录,也会失败并显示状态为“Forbidden”的错误消息:Error from server (InternalError): Internal error occurred: unexpected response: 403

问题出在哪里?我想不通。


对于那些感兴趣的人,这是项目在 GitHub 上的 Git 存储库。

4

2 回答 2

1

此消息表示用户“system:anonymous”没有访问集群的权限。您是否按照文档中的说明登录 crc 集群?

3.3. 访问 OpenShift 集群

oc login -u developer https://api.crc.testing:6443
于 2020-07-21T22:45:20.500 回答
0

这是您运行时的最后一条消息crc start

To access the cluster, first set up your environment by following 'crc oc-env' instructions.
Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443'.
To login as an admin, run 'oc login -u kubeadmin -p xxxx-xxxx-xxxxx-xxxx https://api.crc.testing:6443'.
To access the cluster, first set up your environment by following 'crc oc-env' instructions.

因此,您必须先运行 oc 客户端才能在命令行上使用:

crc oc-env

然后您必须使用 oc 客户端运行登录。在我的安装中是:

oc login -u developer https://api.crc.testing:6443

于 2020-09-23T08:33:00.053 回答