Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cloudytechi147

Pages: [1]
1
I'm trying kubernetes and making some progress, but I'm running into an issue with ingress when trying to make my hello world app publicly available.

SUCCESS WITH DEPLOYMENT AND SERVICE

I created a simple hello world type of nodejs app and pushed the image to my docker hub johnlai2004/swarm2. I successfully created a deployment and service with this yaml file:

nodejs.yaml

Code: [Select]
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodejs-hello
  labels:
    app: nodejs-hello
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nodejs-hello
  template:
    metadata:
      labels:
        app: nodejs-hello
    spec:
      containers:
      - name: nodejs-hello
        image: johnlai2004/swarm2
        ports:
        - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: nodejs-hello-service
spec:
  selector:
    app: nodejs-hello
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
      nodePort: 30000

I uploaded these files to a VPS with a new installation of ubuntu 20.04, minikube, kubectl and docker.

I ran the following commands and got the results I wanted:

Code: [Select]
minikube start --driver=docker
kubectl apply -f nodejs.yaml
minikube service nodejs-hello-service
|-----------|----------------------|-------------|---------------------------|
| NAMESPACE |         NAME         | TARGET PORT |            URL            |
|-----------|----------------------|-------------|---------------------------|
| default   | nodejs-hello-service |        3000 | http://192.168.49.2:30000 |
|-----------|----------------------|-------------|---------------------------|

When I do a wget http://192.168.49.2:30000, I get an index.html file that says hello from nodejs-hello-556dc868-6lrdz at 12/19/2021, 10:29:56 PM. This is perfect.

FAILURE WITH INGRESS

Next, I want to use ingress so that I can see the page at http://website.example.com (replace website.example.com with the actual domain that points to my server). I put this file on my server:

nodejs-ingress.yaml

Code: [Select]
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nodejs-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
    - host: website.example.com
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: nodejs-hello-service
              port:
                number: 3000

And I ran the commands

Code: [Select]
minikube addons enable ingress
kubectl apply -f nodejs-ingress.yaml
kubectl get ingress
NAME             CLASS    HOSTS                   ADDRESS     PORTS   AGE
nodejs-ingress   <none>   website.example.com     localhost   80      15m

But when I visit http://website.example.com with my browser, the browser says it can't connect. Using wget http://website.example.com gave the same connection issue.

Can someone point out what I may have done wrong?

-----------------------------
Code from linux vps hosting.

2
General VPS Hosting Discussion / Connect VPS with domain
« on: December 16, 2021, 02:35:27 AM »
I have a website with the frontend and backend hosted with different hosting providers. The frontend of the app is in Vercel while the backend is in Linode. I also bought a domain in Cheapname, namely example.com. Right now both example dot com and example.com redirect to the Vercel frontend app. The backend is hosted on a VPS and I'm using Nginx for the server. The backend can be accessed using the IP of the cheap VPS.

What I want: Access the frontend app with example.com and example dot com (so far this part works), and access the backend when using the subdomain api.example.com (this does not).

What I have done so far: Changed the DNS for Cheapname and Vercel:

Code: [Select]
A Record    @ 76.76.21.21
CNAME Record    www cname.vercel-dns.com.
CAA Record  0 issue "letsencrypt.org"

Because I want the backend to only be accessed through api.example.com I set the configuration of nginx as follows:

Code: [Select]
server {
    listen 80;
    server_name api.exaple.com;
    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/myuser/myproject;
    }
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/myuser/myproject/myproject.sock;
    }
    client_max_body_size 100M;
}

Then, I put this on Namecheap:

Code: [Select]
A Record    api    xxx.xx.xx.xx
CNAME Record    api  xxx-xx-xx-xx.ip.linodeusercontent.com.

where xxx.xx.xx.xx is the IP address of the VPS

The Problem: When I try to access api.example.com it redirects me to https:\\api.example.com and it gives me a 404 error (Vercel 404!!!). I'm a newbie with DNS, I would appreciate any help!!! Thank you in advance! =)

Pages: [1]