Todos los archivos a los que se hace referencia se incluyen a continuación. Estoy tratando de crear un proxy NGINX para servir mi back-end y front-end con el mismo dominio.
Nginx se ejecuta correctamente, puedo decirlo porque recibo un error 404 de nginx cuando presiono la URL raíz proporcionada por kubectl get ingress .
Sin embargo, cuando llego al punto final url/hello , recibo un error 503 Service Temporarily Unavailable de Nginx.
¿Alguien ha encontrado este error?
Aquí está el archivo yaml para mi kubectl create -f :
kind: Service apiVersion: v1 metadata: name: ingress-nginx namespace: ingress-nginx labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx annotations: # by default the type is elb (classic load balancer). service.beta.kubernetes.io/aws-load-balancer-type: nlb spec: # this setting is to make sure the source IP address is preserved. externalTrafficPolicy: Local type: LoadBalancer selector: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx ports: - name: http port: 80 targetPort: http # - name: https # port: 443 # targetPort: https --- kind: Ingress apiVersion: networking.k8s.io/v1beta1 metadata: name: test-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - http: paths: - path: /hello backend: serviceName: go-hello servicePort: 8080 --- kind: Pod apiVersion: v1 metadata: name: go-hello labels: app: go-hello spec: containers: - name: go-hello image: docker.io/chsclarke11/test-go --- kind: Service apiVersion: v1 metadata: name: go-hello-service spec: selector: app: go-hello ports: - port: 8080 # Default port for imageaquí está el Dockerfile para la aplicación go-hello:
FROM golang:1.12-alpine RUN apk add --no-cache git # Set the Current Working Directory inside the container WORKDIR /app RUN go mod download COPY . . # Build the Go app RUN go build -o main # This container exposes port 8080 to the outside world EXPOSE 8080 # Run the binary program produced by `go install` CMD ["./main"]Aquí está la aplicación simulada go-hello:
package main import ( "fmt" "net/http" ) func main() { fmt.Printf("starting server at http://localhost:8080") http.HandleFunc("/", HelloServer) http.ListenAndServe(":8080", nil) } func HelloServer(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:]) }En la definición de Ingress , especificó un nombre de servicio de backend incorrecto: go-hello que no es compatible con el nombre de servicio que creó para backend - go o-hello-service .
También para el futuro, puede obtener un error 503 de nginx cuando basic-auth está habilitada en Ingress y la anotación nginx.ingress.kubernetes.io/auth-secret hace referencia a un secreto que no existe.
También puede agregar el secreto que falta o eliminar todas las anotaciones de basic-auth del Ingress para resolver esta situación.