Basic App Deployment
Now we have a functional cluster, lets create a basic web application to check its deploying correctly, storage is in use and the ingress works.
Step 1 - Create config YAMLs
We need to create 4 YAML files.
- Pod
- Storage
- Service
- Ingress
webapp_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-webserver-01
namespace: test-apps
labels:
storage: local-longhorn
app: nginx-webserver-01
spec:
containers:
- name: nginx-webserver-01
image: nginx:stable-alpine
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80
volumeMounts:
- name: nginx-webserver-01-webroot
mountPath: "/usr/share/nginx/html"
volumes:
- name: nginx-webserver-01-webroot
persistentVolumeClaim:
claimName: nginx-webserver-01-webroot
restartPolicy: "Never"
webapp_storage.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nginx-webserver-01-webroot
namespace: test-apps
labels:
storage: local-longhorn
app: nginx-webserver-01
spec:
storageClassName: longhorn
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
webapp_service.yaml
kind: Service
apiVersion: v1
metadata:
name: nginx-webserver-01-service
namespace: test-apps
spec:
type: ClusterIP
selector:
app: nginx-webserver-01
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
webapp_ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-webserver-01-ingress
namespace: test-apps
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: "nginx-webserver-01.domain.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-webserver-01-service
port:
number: 80
Apply all four YAML files -
kubectl apply -f webapp_pod.yaml -f webapp_storage.yaml -f webapp_service.yaml -f webapp_ingress.yaml
tip
You can combine YAML files into one, separated by ---
.
Step 2 - Check the resources have deployed
Run the following to list all resources within the namespace used by the above test app -
kubectl
Step 3 - Create a test HTML file.
Coming soon!
Step 4 - Browse to the URL
Coming soon!
Next Step
Next, go to the next step, Portainer Agent.
Or,
Go back to the index page.