在反向代理后面运行goharbor

问题描述 投票:0回答:2

您好,我使用nginx ingress在harbor下可以完美运行http://harbor.domain,我使用Harbor-Helm图表进行安装。

在终端上,我可以将舵图推到http://harbor.domain/chartrepo/

我可以登录

docker login harbor.domain:80

并推送到注册表。

我的挑战是我想通过apache代理访问港口,例如

通过更改https://example.com/harbor,我使用harbour-helm图表重新安装

values.yaml

所以我在externalURL: https://example.com 上添加了以下内容

/etc/apache2/sites-available/example-le-ssl.conf

[如果我这样做 # helmcharts <Location "/chartrepo/"> ProxyPass "http://harbor.domain/chartrepo/" ProxyPassReverse "http://harbor.domain/chartrepo/" </Location> # harbor <Location "/harbor"> ProxyPass "http://harbor.domain/harbor" ProxyPassReverse "http://harbor.domain/harbor" </Location> # registry <Location "/v2"> ProxyPass "http://harbor.domain/v2" ProxyPassReverse "http://harbor.domain/v2" </Location> docker登录返回

docker login example.com

我在注册表日志上收到以下错误

Error response from daemon: login attempt to https://example.com/v2/ failed with status: 503 Service Unavailable

关于我缺少什么的任何想法?

尝试推图表也失败。

error authorizing context: authorization token required

错误正在

helm push --username='username' --password='password' demo-chart.tgz https://example.com/chartrepo/
apache kubernetes docker-registry harbor
2个回答
0
投票

看来您无法授权docker注册表。您可以将变量添加到默认服务帐户,或者我们可以创建Docker注册表机密并将其作为imagepullsecret添加到部署中。

如果要通过imagepullsecret进行此操作,则可以创建模板帮助程序,例如

Error: 404: could not properly parse response JSON: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.41 (Ubuntu) Server at example.com Port 443</address>
</body></html>

然后您可以在部署文件中使用它,如

/* image pull secret */
{{- define "imagePullSecret" }}
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.imageCredentials.registry (printf "%s:%s" .Values.imageCredentials.username .Values.imageCredentials.password | b64enc) | b64enc }}
{{- end }}

整个文件可能看起来像

imagePullSecrets:
      - name: {{.Values.imageCredentials.secretName}}

0
投票

我的第一个问题是apache如何处理代理到https后端的代理,请参见apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Values.appName }} namespace: {{ .Values.namespace }} spec: selector: matchLabels: app: {{ .Values.appName }} replicas: {{ .Values.replicaCount }} template: metadata: labels: app: {{ .Values.appName }} spec: containers: - name: {{ .Values.appName }} image: {{ .Values.image.repository }}:{{ .Values.image.tag }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.hasSecretVolume }} volumeMounts: - name: {{ .Values.appName }}-volume-sec mountPath: {{ .Values.secretVolumeMountPath }} {{- end}} {{- if or .Values.env.configMap .Values.env.secrets }} envFrom: {{- if .Values.env.configMap }} - configMapRef: name: {{ .Values.appName }}-env-configmap {{- end }} {{- if .Values.env.secrets }} - secretRef: name: {{ .Values.appName }}-env-secret {{- end }} {{- end }} ports: - containerPort: {{ .Values.containerPort }} protocol: TCP {{- if .Values.springContainerHealthChecks}} {{ toYaml .Values.springContainerHealthChecks | indent 8 }} {{- end}} {{- if .Values.hasSecretVolume }} volumes: - name: {{ .Values.appName }}-volume-sec secret: secretName: {{ .Values.appName }}-volume-sec {{- end}} {{- if .Values.imageCredentials}} imagePullSecrets: - name: {{.Values.imageCredentials.secretName}} {{- end}}

我已添加到我的虚拟主机how to configure apache server to talk to HTTPS backend server?

/etc/apache2/sites-available/example-le-ssl.conf
© www.soinside.com 2019 - 2024. All rights reserved.