funtoos
funtoos

Reputation: 385

Openshift Enterprise : Unable to connect to deployed app via browser

Deployed a java application in Openshift (3.9 and 3.11), but cannot reach the application via the browser.

Created an REST API application image (OpenLiberty and openjdk 11) and pushed it to openshift docker-registry via a maven build. ImageStream is created. Deployed the image, created a route. The pod comes up. Pod logs shows the liberty server is started. Accessed the pod via Terminal and was able to use curl (http://localhost:9080) in the terminal and test the apis. But when I used the route to access the app from a browser, getting host could not be found error.

I have the same application successfully running on minishift.

Where and what errors do I look for ?

apiVersion: v1
kind: Template
metadata:
  name: ${APPLICATION_NAME}-template
  annotations:
    description: ${APPLICATION_NAME}
objects:
# Application Service      
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      openshift.io/generated-by: OpenShiftNewApp
      service.alpha.openshift.io/serving-cert-secret-name: app-certs
    labels:
      app: ${APPLICATION_NAME}-${APP_VERSION_TAG}
    name: ${APPLICATION_NAME}-${APP_VERSION_TAG}
    namespace: ${NAME_SPACE}
  spec:
    ports:
    - name: 9443-tcp
      port: 9443
      protocol: TCP
      targetPort: 9443
    selector:
      app: ${APPLICATION_NAME}-${APP_VERSION_TAG}
      deploymentconfig: ${APPLICATION_NAME}-${APP_VERSION_TAG}
    sessionAffinity: None
    type: ClusterIP    
# Application Route 
- apiVersion: v1
  kind: Route
  metadata:
    annotations:
      openshift.io/host.generated: "true"
    labels:
      app: ${APPLICATION_NAME}-${APP_VERSION_TAG}
    name: ${APPLICATION_NAME}-${APP_VERSION_TAG}
  spec:
    port:
      targetPort: 9443-tcp
    tls:
      termination: reencrypt
    to:
      kind: Service
      name: ${APPLICATION_NAME}-${APP_VERSION_TAG}
      weight: 100
    wildcardPolicy: None
# APPLICATION DEPLOYMENT CONFIG
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    annotations:
      openshift.io/generated-by: OpenShiftNewApp
    generation: 1
    labels:
      app: ${APPLICATION_NAME}-${APP_VERSION_TAG}
    name: ${APPLICATION_NAME}-${APP_VERSION_TAG}
  spec:
    replicas: 1
    revisionHistoryLimit: 10
    selector:
      app: ${APPLICATION_NAME}-${APP_VERSION_TAG}
      deploymentconfig: ${APPLICATION_NAME}-${APP_VERSION_TAG}
    strategy:
      activeDeadlineSeconds: 21600
      resources: {}
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        annotations:
          openshift.io/generated-by: OpenShiftNewApp
        labels:
          app: ${APPLICATION_NAME}-${APP_VERSION_TAG}
          deploymentconfig: ${APPLICATION_NAME}-${APP_VERSION_TAG}
      spec:
        affinity:
          podAntiAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                  - key: app
                    operator: In
                    values:
                    - ${APPLICATION_NAME}-${APP_VERSION_TAG}
#                  - key: region
#                    operator: In
#                    values:
#                    - ${TARGET_ENVIRONMENT}
                topologyKey: "kubernetes.io/hostname"
        containers:
        - image: ${APPLICATION_NAME}:${TAG}
          imagePullPolicy: Always
#          livenessProbe:
#            failureThreshold: 3
#            httpGet:
#              path: ${APPLICATION_HEALTH_CHECK_URL}
#              port: 8080
#              scheme: HTTP
#            initialDelaySeconds: 15
#            periodSeconds: 15
#            successThreshold: 1
#            timeoutSeconds: 25
#          readinessProbe:
#            failureThreshold: 3
#            httpGet:
#              path: ${APPLICATION_READINESS_CHECK_URL}
#              port: 8080
#              scheme: HTTP
#            initialDelaySeconds: 10
#            periodSeconds: 15
#            successThreshold: 1
#            timeoutSeconds: 25
          name: ${APPLICATION_NAME}-${APP_VERSION_TAG}
          envFrom:
          - configMapRef:
              name: server-env
          - secretRef:
              name: server-env
          env:
          - name: KEYSTORE_PASSWORD
            valueFrom:
              secretKeyRef:
                name: keystore-secret
                key: KEYSTORE_PASSWORD
          - name: KEYSTORE_PKCS12
            value: /var/run/secrets/java.io/keystores/keystore.pkcs12
          ports:
          - containerPort: 9443
            protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
          - name: app-certs
            mountPath: /var/run/secrets/openshift.io/app-certs
          - name: keystore-volume
            mountPath: /var/run/secrets/java.io/keystores
        initContainers:
        - name: pem-to-keystore
          image: registry.access.redhat.com/redhat-sso-7/sso71-openshift:1.1-16
          env:
            - name: keyfile
              value: /var/run/secrets/openshift.io/app-certs/tls.key
            - name: crtfile
              value: /var/run/secrets/openshift.io/app-certs/tls.crt
            - name: keystore_pkcs12
              value: /var/run/secrets/java.io/keystores/keystore.pkcs12
            - name: keystore_jks
              value: /var/run/secrets/java.io/keystores/keystore.jks
            - name: password
              valueFrom:
                secretKeyRef:
                  name: keystore-secret
                  key: KEYSTORE_PASSWORD
          command: ['/bin/bash']
          args: ['-c', "openssl pkcs12 -export -inkey $keyfile -in $crtfile -out $keystore_pkcs12 -password pass:$password"]
          volumeMounts:
            - name: keystore-volume
              mountPath: /var/run/secrets/java.io/keystores
            - name: app-certs
              mountPath: /var/run/secrets/openshift.io/app-certs
        dnsPolicy: ClusterFirst
        restartPolicy: Always
        schedulerName: default-scheduler
        securityContext: {}
        terminationGracePeriodSeconds: 30
        volumes:
        - name: app-certs
          secret:
            secretName: app-certs
        - name: keystore-volume
          emptyDir: {}
    test: false
    triggers:
    - type: ConfigChange
    - imageChangeParams:
        automatic: true
        containerNames:
        - ${APPLICATION_NAME}-${APP_VERSION_TAG}
        from:
          kind: ImageStreamTag
          name: ${APPLICATION_NAME}:${APP_VERSION_TAG}
      type: ImageChange


parameters:
- name: APPLICATION_NAME
  description: Name of the app
  value: microservice
  required: true
- name: APP_VERSION_TAG
  description: TAG of the image stream tag
  value: latest
  required: true
- name: NAME_SPACE
  description: Namespace
  value: microservice--sbx--microservice
  required: true
- name: DOMAIN_URL
  description: DOMAIN_URL
  value: microservice-myproject
  required: true
- name: APPLICATION_LIVENESS_CHECK_URL
  description: LIVENESS Check URL
  value: /health
  required: true
- name: APPLICATION_READINESS_CHECK_URL
  description: READINESS Check URL
  value: /microservice/envvariables
  required: true
- name: DOCKER_IMAGE_REPO
  description: Docker Image Repository
  value: docker-registry-default.apps.xxxx.xxx.xxx.xxx.com
  required: true

Upvotes: 1

Views: 399

Answers (0)

Related Questions