Cannot access Django site using a Service

I’m following this tutorial: How To Deploy a Scalable and Secure Django Application with Kubernetes | DigitalOcean

I’m stuck in Step 7 - ## Allowing External Access using a Service now.

I configured my service file, and I can view my port and External IP address

(projectenv) D:\Interscale\Project\CustomerPortals\Customer_Portals\backend\myproject\yaml>kubectl get svc app
app    NodePort   <Cluster-IP>   <none>        8000:<My Port>/TCP   17s

(projectenv) D:\Interscale\Project\CustomerPortals\Customer_Portals\backend\myproject\yaml>kubectl get node -o wide
NAME                           STATUS   ROLES    AGE    VERSION   INTERNAL-IP   EXTERNAL-IP     OS-IMAGE                         KERNEL-VERSION           CONTAINER-RUNTIME
client-portal-nodepool-qjfch   Ready    <none>   3d5h   v1.25.4   <InternalIP>    <My External IP>   Debian GNU/Linux 11 (bullseye)   5.18.0-0.deb11.4-amd64   containerd://1.4.13

But when I’m trying to access my site, I got this error: # This site can’t be reached

<My External IP address> took too long to respond.

This is the format I input in site: http://<External IP address>:<Port>/admin/

And I runned my django project locally at first, it works fine.

I think the problem is because I’m using the Private Docker Registry. I checked the tutorial in Kubernetes setting the credentials. But I think the configuration process is not so clear. This is the tutorial link: Pull an Image from a Private Registry | Kubernetes

I don’t know what should I put for <your-registry-server>.

kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

and I don’t know how to import the ‘regcred’ when I have created it.

So I just modified my Deploy.yaml file like this:

apiVersion: apps/v1
kind: Deployment
  name: portals-app
    app: app
  replicas: 2
      app: app
        app: app
        - image: xichen9718/portals_docker_repository:latest
          name: app
          - secretRef:
              name: app-secret
          - configMapRef:
              name: app-config
            - containerPort: 8000
              name: gunicorn
        - name: regcred

Can anyone help me with this problem please

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 25, 2023

Hi there,

What I could suggest is to use a Load Balancer as a service rather than NodePort.

  type: LoadBalancer
    app: polls
    - name: http
      protocol: TCP
      port: 8000
      targetPort: 8000

For more information you can take a look at the following documentation:

Hope that this helps!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.