jfrog / charts

JFrog official Helm Charts
https://jfrog.com/integration/helm-repository/
Apache License 2.0
255 stars 442 forks source link

artifactory - can I use ingress sub path ? #653

Closed Hokwang closed 4 years ago

Hokwang commented 4 years ago

Hello.

I want to use artifactory with https://my.company.com/artifactory-stage URL.

Is it possible? (using including docker registry case or excluding docker registry case)

I can't deploy with sub path, can you provide simple example?

my values.yaml is

ingress:
  enabled: true
  defaultBackend:
    enabled: false
  hosts:
    - nwse.sec.samsung.net
  path: /artifactory-stage
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/add-base-url : "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^/(v2)/token /$2/artifactory/api/docker/null/v2/token;
      rewrite ^/(v2)/([^\/]*)/(.*) /$2/artifactory/api/docker/$2/$1/$3;
  tls:
    - secretName: ingress-tls
      hosts:
        - my.company.com

artifactory:
  image:
    repository: "docker.bintray.io/jfrog/artifactory-oss"
  masterKey: 5a406dd12321a3832c25532c0893630ce3657a89a52c7978ed8237bc75aa1744
  joinKey: 5a406dd12321a3832c25532c0893630ce3657a89a52c7978ed8237bc75aa1744

  accessAdmin:
    ip: "*"
    password: "1qaz2wsx"

  persistence:
    enabled: true
    storageClass: "nfs-client-stage"

nginx:
  enabled: false

postgresql:
  postgresqlPassword: "1qaz2wsx"
  persistence:
    enabled: false

When I access my.company.com/artifactory-stage, it moved to my.company.com/artifactory and return 404 not found error.

Hokwang commented 4 years ago

I found out ingress.path does not work.

$ k get ing artifactory-stage-artifactory -n artifactory-stage -o yaml
<snip>
spec:
  rules:
  - host: nwse.sec.samsung.net
    http:
      paths:
      - backend:
          serviceName: artifactory-stage-artifactory
          servicePort: 8082
        path: /
      - backend:
          serviceName: artifactory-stage-artifactory
          servicePort: 8081
        path: /artifactory/

I guess this is bug.

Hokwang commented 4 years ago

@danielezer can you helm me?

danielezer commented 4 years ago

@Hokwang You can try something like the following https://github.com/jfrog/charts/issues/306#issuecomment-520211341. Let me know if it works

Hokwang commented 4 years ago

@danielezer .Values.nginx.externalPortHttp is deprecated and I don't use nginx.

nginx:
  enabled: false

so serviceName and servicePort does not match with your link.

danielezer commented 4 years ago

Try to change it to the artifactory service name and the artifactory external service port

Hokwang commented 4 years ago

I did run below commands,

# cat myvalues.yaml
ingress:
  enabled: true
  defaultBackend:
    enabled: false
  hosts:
    - my.company.net
  path: /artifactory-stage
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  tls:
    - secretName: ingress-tls
      hosts:
        - my.company.net

artifactory:
  image:
    repository: "docker.bintray.io/jfrog/artifactory-pro"
    license:
      secret: artifactory-license
      dataKey: art.lic
  masterKey: 5a406dd12321a3832c25532c0893630ce3657a89a52c7978ed8237bc75aa1744
  joinKey: 5a406dd12321a3832c25532c0893630ce3657a89a52c7978ed8237bc75aa1744

  accessAdmin:
    ip: "*"
    password: "1qaz2wsx"

  persistence:
    enabled: false

nginx:
  enabled: false

postgresql:
  postgresqlPassword: "1qaz2wsx"
  persistence:
    enabled: false

# helm install artifactory-stage -n artifactory-stage -f myvalues.yaml jfrog/artifactory
# k get ing -n artifactory-stage 
NAME                            HOSTS                  ADDRESS   PORTS     AGE
artifactory-stage-artifactory   my.company.net             80, 443   30s

# k edit ing artifactory-stage-artifactory -n artifactory-stage
<snip>
spec:
  rules:
  - host: my.company.net
    http:
      paths:
      - backend:
          serviceName: artifactory-stage-artifactory
          servicePort: 8082
        path: /artifactory-stage
      - backend:
          serviceName: artifactory-stage-artifactory
          servicePort: 8081
        path: /artifactory-stage/artifactory/
      - backend:
          serviceName: artifactory-stage-artifactory
          servicePort: 8082
        path: /artifactory-stage/webapp

8082 / is created automatically, I edited /artifactory-stage and 8081 /artifactory/ is also created, I edited /artifactory-stage/artifactory/ and I added 8082 /artifactory-stage/webapp Do you mean this spec? Anyway still not works and I tried to change this spec so many times but no luck.

Hokwang commented 4 years ago

@danielezer can you test this?

danielezer commented 4 years ago

@Hokwang Hey, sorry for the delay in my response. I have tried achieving what you are aiming for and I managed to do it with the following values.yaml:

ingress:
  enabled: true
  defaultBackend:
    enabled: false
  hosts:
    - my.company.net
  path: /artifactory-stage
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite "(?i)/artifactory-stage(/|$)(.*)" /$2 break;

  additionalRules: |
    - host: my.company.net
      http:
        paths:
          - path: /artifactory-stage
            backend:
              serviceName: {{ template "artifactory.fullname" . }}
              servicePort: {{ .Values.artifactory.externalPort }}

Please let me know if it works out for you

Hokwang commented 4 years ago

Thanks for your kind reply, but I didn't make it success. I gave up. my last value.yaml is

ingress:
  enabled: true
  defaultBackend:
    enabled: false
  hosts:
    - my.company.net
  routerPath: /artifactory-stage/
  artifactoryPath: /artifactory-stage/artifactory
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite "(?i)/artifactory-stage(/|$)(.*)" /$2 break;
  tls:
    - secretName: ingress-tls
      hosts:
        - my.company.net
danielezer commented 4 years ago

@Hokwang Sorry about that... If you gather the energy to try again, you can use my values, I have confirmed that they worked and I was able to access my Artifactory server with /artifactory-stage

skulasekar commented 4 years ago

@danielezer I have been running into the same issue as @Hokwang. Can you post the values.yml that worked for you?

danielezer commented 4 years ago

@skulasekar take a look at this comment - https://github.com/jfrog/charts/issues/653#issuecomment-609415700. These are the values that worked for me. Hope this helps

adityajalkhare commented 1 year ago

@danielezer I had tried both your way and @Hokwang 's. Didn't work. The UI is stuck at loading screen.

My values.yaml -

  ingress:
    enabled: true
    defaultBackend:
      enabled: false
    tls:
    hosts: 
    - ''
    className: my-custom-ingress-class
    routerPath: /jcr/
    artifactoryPath: /jcr/artifactory/
    annotations:
      nginx.ingress.kubernetes.io/rewrite-target: /$2
      nginx.ingress.kubernetes.io/proxy-body-size: "0"
      nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
      nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
      nginx.ingress.kubernetes.io/configuration-snippet: |
        rewrite ^/(v2)/token /artifactory/api/docker/null/v2/token;
        rewrite ^/(v2)/([^\/]*)/(.*) /artifactory/api/docker/$2/$1/$3;

Also tried by changing annotation to -

      nginx.ingress.kubernetes.io/configuration-snippet: |
        rewrite ^/(v2)/token /artifactory/api/docker/null/v2/token;
        rewrite ^/(v2)/([^\/]*)/(.*) /artifactory/api/docker/$3/$2/$4;

and

      nginx.ingress.kubernetes.io/configuration-snippet: |
        rewrite ^/(v2)/token /jcr/artifactory/api/docker/null/v2/token;
        rewrite ^/(v2)/([^\/]*)/(.*) /jcr/artifactory/api/docker/$3/$2/$4;

Also tried /jfrog/artifactory instead of /jcr/artifactory in both annotations and artifactoryPath