0

The docker image stored in the ACR was distributed to the AKS using azure devops pipelines. Then an error occurs.

enter image description here

This is a docker-compose file that creates a docker image for me to use.

# docker-compose.yml

version: "3.9"
services:
  spring-app:
    build:
      context: .
      dockerfile: Dockerfile-app
    image: acrprod0327.azurecr.io/production/spring-app
    container_name: spring-app
    ports:
      - "8080:8080"
  web:
    build:
      context: .
      dockerfile: Dockerfile-nginx
    image: acrprod0327.azurecr.io/production/nginx-alpine
    container_name: nginx-alpine
    ports:
      - "80:80"
    depends_on:
      - spring-app

Below is the ingress & service & deployment file distributed to AKS.

# ingress.yml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: prefix-based
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx-svc
            port:
              number: 80
# spring-service.yml

apiVersion: v1
kind: Service
metadata:
  name: spring-svc
spec:
  selector:
    app: spring-app
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
# spring-deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: spring-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: spring-app
  template:
    metadata:
      labels:
        app: spring-app
    spec:
      containers:
        - name: spring-app
          image: acrprod0327.azurecr.io/production/spring-app
          ports:
          - containerPort: 8080
          env:
            - name: SPRING_PROFILES_ACTIVE
              value: dev
# nginx-service.yml

apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  selector:
    app: nginx-app
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: LoadBalancer
# nginx-deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-app
  template:
    metadata:
      labels:
        app: nginx-app
    spec:
      containers:
        - name: nginx-alpine
          image: acrprod0327.azurecr.io/production/nginx-alpine
          ports:
          - containerPort: 80

Below are the errors that occur when you run the docker run command on the docker image.

enter image description here

Below is the contents of the nginx.conf file.

# nginx.conf

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    upstream backend {
        server spring-app:8080;
    }

    server {
        listen 80;
        server_name localhost;

        location / {
            resolver 127.0.0.1 [::1]:8080 valid=30s;
            proxy_pass http://backend;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  65;
    include /etc/nginx/conf.d/*.conf;
}

It is speculated that the reason why nginx-deploy exceeded its progress deadline is the problem of setting up the nginx.conf file.

However, I think there will be something I am missing, so I would like to get feedback.

  1. I added the nginx.conf resolver setting to fix the error host not found.
  2. Reviewed 2 docker images I created. 2-1. Problem with nginx image.
  3. Modified the service & deployment file.

The same error occurs

0 Answers0