- Clone SFTP-Parsing Log source from github: https://github.com/vominhtri1991/sftp_logs_review_web.git
- Prepare Dockerfile with below content for building new image
FROM alpine
LABEL maintainer="vmt1991@gmail.com"
RUN apk add --update python3 py-pip
RUN pip install --upgrade pip setuptools
RUN pip install --upgrade django
COPY . /
WORKDIR /sftp_logs_review_web
ENTRYPOINT ["python3","manage.py","runserver","0:8000"]
EXPOSE 8000
- Building Django app SFTP-Parsing Log image with tag django-app:v1
- List image built
- Running container from this image with publish port 8000
- Browsing to Django App Using public port and domain name configure in settings.py (ALLOWED_HOST) of source project
- Export image to file for importing to Tanzu Worker Node later
- Login to Supervisor Cluster:
# kubectl vsphere login --server=<IP Supervisor Cluster> -u devops@vsphere.local --insecure-skip-tls-verify
- On Supervisor Node run this command to get password string SSH access to Control Plane Node and Worker Node of TKG Cluster
# kubectl -n <namespace> get secrets <tkg cluster secret> -o jsonpath={.data.ssh-passwordkey} | base64 -d
- Use WinSCP copy file Django app image to Worker Node of TKG Cluster use account system-vmware-user and decoded password
- SSH to Worker Node of TKG Cluster
- Import Django app image to K8s namespace
# sudo ctr -n=k8s.io image import --base-name django-app:v1 django-app.tar
- Listing images
# sudo crictl images | grep -i django
- Login to TKG cluster
# kubectl vsphere login --server=$SC_IP --tanzu-kubernetes-cluster-name tkc-1 --tanzu-kubernetes-cluster-namespace $NAMESPACE --vsphere-username administrator@vsphere.local --insecure-skip-tls-verify
- Prepare yaml file and deploy pod and service from Django app image:
apiVersion: apps/v1
kind: Deployment
metadata:
name: webserver
spec:
replicas: 1
selector:
matchLabels:
app: webapp
template:
metadata:
labels:
app: webapp
spec:
containers:
- image: docker.io/library/django-app:v1
imagePullPolicy: Never
name: app-container
---
apiVersion: v1
kind: Service
metadata:
labels:
app: webserver
name: webserver
spec:
ports:
- port: 8000
protocol: TCP
targetPort: 8000
selector:
app: webapp
sessionAffinity: None
type: LoadBalancer
- Check Load Balancer EXTERNAL IP of haproxy for access Django service:
- Browsing to Django App using EXTERNAL IP published by haproxy