我运行了以下命令:
kubectl create secret tls nexus-tls --cert cert.crt --key privateKey.pem
其中cert.crt
包含我的证书,privateKey.pem
包含我的私钥(使用CloudFlare提供(。
然后,我安装了具有以下配置的stable/sonatype-nexus
Helm图:
nexusProxy:
env:
nexusDockerHost: containers.<<NEXUS_HOST>>
nexusHttpHost: nexus.<<NEXUS_HOST>>
nexusBackup:
enabled: true
nexusAdminPassword: <<PASSWORD>>
env:
targetBucket: gs://<<BACKUP_BUCKET_NAME>>
persistence:
storageClass: standard
ingress:
enabled: true
path: /*
annotations:
kubernetes.io/ingress.allow-http: true
kubernetes.io/tls-acme: true
kubernetes.io/ingress.class: gce
kubernetes.io/ingress.global-static-ip-name: <<STATIC_IP_ADDRESS_NAME>>
tls:
enabled: true
secretName: nexus-tls
persistence:
storageClass: standard
storageSize: 1024Gi
resources:
requests:
cpu: 250m
memory: 4800Mi
通过运行命令:
helm install -f values.yaml stable/sonatype-nexus
此处记录了此图表的可能配置值。
当我访问http://nexus.<<NEXUS_HOST>>
时,我可以访问Nexus存储库。但是,当我访问https://nexus.<<NEXUS_HOST>>
时,我会收到混合内容警告,因为正在提供HTTP资源。
如果我将nexusProxy.env.enforceHttps
环境变量设置为true,当我访问https://nexus.<<NEXUS_HOST>>
时,我会得到一个回复,看起来像:
HTTP access is disabled. Click here to browse Nexus securely: https://nexus.<<NEXUS_HOST>>.
如何确保Nexus得到安全服务?我是否犯了配置错误,或者问题出在其他地方?
由于遗留的原因,我必须在GKE上建立关系。虽然这个问题并没有直接说明它在谷歌云上,但gs://
和ingress.class: gce
表明它是;尽管宣惠的老答案是关于AWS的。
我花了很长时间让Nexus TLS在GKE上工作,但我终于成功了。Google Ingress资源并不是最稳定的。如果您正在迭代,它们可能会楔入,并且您可能会发现终结器由于在L4 ILB清理上卡住而无法完成。GCP中只有无辜的部署和删除周期,事情变得如此糟糕,以至于我不得不丢弃项目,开始新的项目进行测试,最终找到一个有效的组合。
我的头盔values.yaml
有以下内容。注意,我也在使用Terraform,所以在运行Helm之前,我的${variables}
被Terraform替换为我的特定环境设置。
service:
type: ClusterIP
annotations:
cloud.google.com/neg: '{"ingress": true}'
cloud.google.com/backend-config: '{"ports": {"8081":"sonatype-backendcfg"}}'
ingress:
ingressClassName: null # on GCP, null this, and use annotations instead
enabled: true
hostPath: / # don't use /* that is suggested multiple places
hostRepo: ${sonatype_dns_name} # public facing FQDN
annotations:
ingress.gcp.kubernetes.io/pre-shared-cert: "${gce_ssl_cert_name}"
kubernetes.io/ingress.class: "gce-internal"
kubernetes.io/ingress.allow-http: "false"
# unrelated hint - I use external-dns for DNS registration
external-dns.alpha.kubernetes.io/hostname: "${sonatype_dns_name}."
tls:
- secretName: "${tls_secret_name}"
hosts:
- "${sonatype_cluster_dns_name}" # the svc.cluster.local FQDN
在运行Helm之前,我的安装程序将TLS证书放置在GCE证书存储中,供ILB使用。
同样在Helm之前,${tls_secret_name}
kubesecret是用密钥名tls.crt
和tls.key
中的cert准备的(许多其他应用程序使用这种模式(。
我还有一个backendconfig
资源:
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: sonatype-backendcfg
namespace: sonatype
spec:
healthCheck:
checkIntervalSec: 30
healthyThreshold: 1
port: 8081
requestPath: /service/rest/v1/status
timeoutSec: 15
type: HTTP
unhealthyThreshold: 10
Nexus的员工不再支持这种情况了,所以我们正在努力搬到Harbor,这样我们就可以取消我们的Nexus许可证。
如果ELB提供纯http流量,请将其添加到LoadBalancer服务注释中。
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http