This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed2 years ago.
I have little k8s cluster in my machine and I try to make something for learn but I stack right now.
I have 2 app, one of mysql and another one wordpress and they are working good. When I give a LoadBalancer type for wordpress, it's taking a ip and I can see in my browser.
So I want to create a Ingress and call by hostname but Ingress not take a Loadbalancer IP..Am I doing wrong anythin?
This is my Ingress configuration
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: wp-ingress kubernetes.io/ingress.class: nginx labels: name: wp-ingressspec: rules: - host: wordpress.pandora.local http: paths: - pathType: Prefix path: "/" backend: service: name: wp-svc port: number: 80 - host: phpmyadmin.pandora.local http: paths: - pathType: Prefix path: "/" backend: service: name: phpmyadmin-svc port: number: 80and problem
# kg ingressNAME CLASS HOSTS ADDRESS PORTS AGEwp-ingress <none> wordpress.pandora.local,phpmyadmin.pandora.local 80 38mI'm using a Metallb for loadbalancer and I know it's work becasue of wordpress, but if you want to see
kg svc -ANAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEcalico-apiserver calico-api ClusterIP 10.108.149.243 <none> 443/TCP 45hcalico-system calico-kube-controllers-metrics ClusterIP 10.100.211.40 <none> 9094/TCP 45hcalico-system calico-typha ClusterIP 10.107.217.253 <none> 5473/TCP 45hdefault kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 45hdefault mysql-svc ClusterIP 10.103.110.242 <none> 3306/TCP 3h1mdefault phpmyadmin-svc ClusterIP 10.105.195.144 <none> 80/TCP 156mdefault wp-svc ClusterIP 10.100.96.37 <none> 80/TCP 126mingress-nginx ingress-nginx-controller LoadBalancer 10.99.196.206 192.168.188.20 80:30986/TCP,443:32709/TCP 49mingress-nginx ingress-nginx-controller-admission ClusterIP 10.99.212.249 <none> 443/TCP 49mkube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 45hHow can I troubleshoot the situation
- I really don't understand this. When I entered a reply with "answer your question" recently, someone warned me that I need to add first post. Now the opposite is said. Which one is right? @ArnavThoratthargalin– thargalin2022-04-10 07:51:32 +00:00CommentedApr 10, 2022 at 7:51
- Adding an answer is better for readability.Viradex– Viradex2022-04-10 08:13:12 +00:00CommentedApr 10, 2022 at 8:13
2 Answers2
I solved. Thank for help :)The problem was about to ingress class.
kind: Ingressmetadata: name: wp-ingressspec: rules: - host: wordpress.pandora.local http: paths: - pathType: Prefix path: "/" backend: service: name: wp-svc port: number: 80 - host: phpmyadmin.pandora.local http: paths: - pathType: Prefix path: "/" backend: service: name: phpmyadmin-svc port: number: 80 ingressClassName: nginxI added the last lineingressClassName: nginx defination and it's work!
kg ingressNAME CLASS HOSTS ADDRESS PORTS AGEwp-ingress nginx wordpress.pandora.local,phpmyadmin.pandora.local 192.168.88.20 80 5h19m1 Comment
Even though there's already an accepted answer here, I wanted to show steps on troubleshooting this issue.
Full source codehere.
Step 1
Check your ingress.
kubectl get ingress -n localYou'll see that the controller hasn't assigned any address to the hostname.
Step 2
Ensure you have installed Ingress Controller. Follow instructionshere.
Step 3
Check the ingress controller logs. I'm using Kubernetes dashboard here. You can usekubectl if you'd like.The error will tell you the problem.
This is the error seen in the logs:
"Ignoring ingress because of error while validating ingress class" ingress="local/test-app-release-test-app-api" error="ingress does not contain a valid IngressClass"Step 4
Find theIngressClass. You can get this by either running this command:kubectl get ingressclasses or finding it through K8s dashboard.
Command way:
Dashboard way:
Step 5
Update your ingress
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: test-app-release-test-app-api labels: helm.sh/chart: test-app-api-0.1.0 app.kubernetes.io/name: test-app-api app.kubernetes.io/instance: test-app-release app.kubernetes.io/version: "1.16.0" app.kubernetes.io/managed-by: Helm annotations: nginx.ingress.kubernetes.io/rewrite-target: /$2 nginx.ingress.kubernetes.io/use-regex: "true"spec: ingressClassName: nginx # <------ THIS GUY rules: - host: "chart-example.local" http: paths: - path: /my-test-app(/|$)(.*) pathType: ImplementationSpecific backend: service: name: test-app-release-test-app-api port: number: 80Step 6
Deploy the app. At this point, you'll be able to see the address assigned by the controller.
kubectl get ingress -n localComments
Explore related questions
See similar questions with these tags.
