<p>I have hangfire dashboard working properly on local environment. Now, I'm trying to setup it as a container (pod) inside my cluster, deployed to azure so I can access hangfire dashboard through its url. However, I'm having issue access to it.</p>
<p>Below is my setup:</p>
<pre><code>        [UsedImplicitly]
        public void Configure(IApplicationBuilder app)
        {
            var hangFireServerOptions = new BackgroundJobServerOptions
            {
                Activator = new ContainerJobActivator(app.ApplicationServices)
            };

            app.UseHealthChecks(&quot;/liveness&quot;);
            app.UseHangfireServer(hangFireServerOptions);

            app.UseHangfireDashboard(&quot;/hangfire&quot;, new DashboardOptions()
            {
                AppPath = null,
                DashboardTitle = &quot;Hangfire Dashboard&quot;,
                Authorization = new[]
                {
                    new HangfireCustomBasicAuthenticationFilter
                    {
                        User = Configuration.GetSection(&quot;HangfireCredentials:UserName&quot;).Value,
                        Pass = Configuration.GetSection(&quot;HangfireCredentials:Password&quot;).Value
                    }
                }
            });

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =&gt;
            {
                endpoints.MapControllers();
            });

            HangfireJobScheduler.ScheduleJobs(app.ApplicationServices.GetServices&lt;IScheduledTask&gt;()); //serviceProvider.GetServices&lt;IScheduledTask&gt;()
        }
</code></pre>
<p>Service.yml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: task-scheduler-api
spec:
  ports:
  - port: 80
    targetPort: 80
    name: http
  - port: 443
    targetPort: 443
    name: https
  selector:
    app: task-scheduler-api     
</code></pre>
<p>Deployment.yml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: task-scheduler
spec:
  selector:
    matchLabels:
      app: task-scheduler  
  template:
    metadata:
      labels:
        app: task-scheduler
    spec:
      containers:
      - name: task-scheduler
        image: &lt;%image-name%&gt;
        # Resources and limit
        resources:
          requests:
            cpu: &lt;%cpu_request%&gt;
            memory: &lt;%memory_request%&gt;
          limits:
            cpu: &lt;%cpu_limit%&gt;
            memory: &lt;%memory_limit%&gt;
        ports:
        - name: http
          containerPort: 80
        - name: https
          containerPort: 443        
        readinessProbe:
          httpGet:
            path: /liveness
            port: 80
          initialDelaySeconds: 3
          periodSeconds: 5
          timeoutSeconds: 30
        livenessProbe:
          httpGet:
            path: /liveness
            port: 80
          initialDelaySeconds: 15
          periodSeconds: 10
          timeoutSeconds: 5
          failureThreshold: 7
</code></pre>
<p>Ingress.yml</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;    
    cert-manager.io/cluster-issuer: letsencrypt
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: task-scheulder-api-ingress
  namespace: default
spec:
  rules:
    - host: example.com
      http:
        paths:
        - path: /          
          pathType: Prefix
          backend:
            service:
              name: task-scheduler-api
              port:
                number: 80
  tls:
    - hosts:
        - example.com
      secretName: task-scheduler-tls-production        
</code></pre>
<p>I'm trying to access the dashboard by running: example.com/hangfire, but got 503 Service Temporarily Unavailable.</p>
<p>I'm checking logs on the pod. Every seem to be fine:</p>
<pre><code>...
...
Content root path: /data
Now listening on: http://0.0.0.0:80
Now listening on: https://0.0.0.0:443
Application started. Press Ctrl+C to shut down.
....
</code></pre>
<p>Would anyone know what I'm missing and how to resolve it ? Thank you</p>

Hoang Minh
<p>I have figured out the issue. The main issue is that I did not have the match value for selector app in <code>deployment.yml</code> and <code>service.yml</code>. If I do <code>kubectl get ep</code>, it is showing me that I do not have any endpoint assign to the task scheduler pod, meaning that it is not really deployed yet.</p>
<p>As soon as I updated values in the <code>deployment.yml</code> and <code>service.yml</code>, url is accessible.</p>
<p><code>service.yml</code></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: task-scheduler-api
spec:
  ports:
  - port: 80
    targetPort: 80
    name: http
  - port: 443
    targetPort: 443
    name: https
  selector:
    app: task-scheduler-api  # This needs to match with value inside the deployment   
</code></pre>
<p><code>deployment.yml</code></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: task-scheduler
spec:
  selector:
    matchLabels:
      app: task-scheduler  # This needs to match with value in service
  template:
    metadata:
      labels:
        app: task-scheduler # This needs to match as well
    spec:
      containers:
      - name: task-scheduler
        image: &lt;%image-name%&gt;
        # Resources and limit
        resources:
          requests:
            cpu: &lt;%cpu_request%&gt;
            memory: &lt;%memory_request%&gt;
          limits:
            cpu: &lt;%cpu_limit%&gt;
            memory: &lt;%memory_limit%&gt;
        ports:
        - name: http
          containerPort: 80
        - name: https
          containerPort: 443        
        readinessProbe:
          httpGet:
            path: /liveness
            port: 80
          initialDelaySeconds: 3
          periodSeconds: 5
          timeoutSeconds: 30
        livenessProbe:
          httpGet:
            path: /liveness
            port: 80
          initialDelaySeconds: 15
          periodSeconds: 10
          timeoutSeconds: 5
          failureThreshold: 7
</code></pre>
<p>Hopefully someone would find it useful. Thank you</p>
