$ kubectl apply -f mysql-secret.yaml
Create storage on hard disk before creating the volume and claim:
$ sudo mkdir -p /opt/mysql2/data
$ kubectl apply -f mysql-storage.yaml
$ kubectl apply -f mysql-deployment.yaml
$ kubectl apply -f mysql-service2.yaml
$ kubectl run -it --rm --image=mysql --restart=Never mysql-client -- mysql --host mysql --password=123456
Initialize databse by using init_db.sql (just copy and past the contents of the file)
Use 'exit' to quit
$ cd backend_all/
$ sudo docker build . -t course-api-v3
Dont't forget to push it to the registry as localhost:32000/course-api-v3
$ kubectl apply -f course-api-deployment.yaml
$ kubectl apply -f course-api-service.yaml
$ cd front/
$ npm install
$ npm run-script build
Make sure you have the 'build' folder in your current directory
$ sudo docker build . -t course-ui:v17
Dont't forget to push it to the registry as localhost:32000/course-ui:v17
$ kubectl apply -f course-ui-deployment.yaml
$ kubectl apply -f course-ui-service.yaml
Open the browser and use localhost:30002 to access
kubectl apply -f cert/selfsigned-cluster-issuer.yaml
kubectl apply -f cert/selfsigned-ca.yaml
$ cd front/
$ kubectl apply -f course-ui-ingress.yaml
Add 127.0.0.1 my-course.com to the /etc/hosts
Open the browser and use my-course.com to access
unless there are other network rules applied, no pod can communicate with any other pod.
$ kubectl apply -f policy-deny-all.yaml
This will make the application cannot be accessed by domain name my-course.com
allow traffic only from the api pod to the mysql pod
$ kubectl apply -f db-allow.yaml
allow traffic only from the frontend pod to the api pod
$ kubectl apply -f api-allow.yaml
Use the combination of network policies 1 to 3 to secure the application
deny all the traffic from other namespaces while allowing all the traffic coming from the same namespace the pod deployed to
$ kubectl apply -f deny-from-other-namespaces.yaml
If you deploy the application in another namespace (e.g. ns-course), please change the configuration in the yaml file accordingly.
kubectl apply -f role_control.yaml
create 2 Role and 1 ClusterRole
create 3 service accounts binded to roles.
Original project (no deployment): https://github.com/Allirey/test_task134