This repo contains kubernetes scripts to be executed in your Ubuntu instance after logging in as the kOps user.
- Make sure you have an AWS Kubernetes cluster set up (follow Task 2.1 and 2.2 from Project 5 in your AWS Ubuntu instance).
- Create a
regcred
secret which contains your Dockerhub credentials. Replace variables with your info.kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=<YOUR_DOCKER_USERNAME> --docker-password=<YOUR DOCKER PASSWORD> --docker-email=<YOUR DOCKER EMAIL>
- Set up MySQL pods through the helm chart.
helm install mysql --set auth.rootPassword=root,auth.database=murphymovies,auth.username=murphyuser,auth.password='My7$Password',secondary.persistence.enabled=true,secondary.persistence.size=2Gi,primary.persistence.enabled=true,primary.persistence.size=2Gi,architecture=replication,auth.replicationPassword=texera,secondary.replicaCount=1 oci://registry-1.docker.io/bitnamicharts/mysql
Test by running kubectl get pods
, both mysql pods should be in RUNNING
state and READY (1/1)
.
4. Populate MySQL database =>
- Run
kubectl exec -it pod/mysql-primary-0 -- /bin/bash
. - Run
mysql -u root -p
& enter password asroot
. - Run the SQL scripts from Murphy Movies repo.
- Grant
murphyuser
privileges:GRANT ALL PRIVILEGES ON * . * TO 'murphyuser'@'%';
- Enable ingress in your AWS cluster.
- Run the following to install ingress-nginx.
helm upgrade --install ingress-nginx ingress-nginx \ --repo https://kubernetes.github.io/ingress-nginx \ --namespace ingress-nginx --create-namespace
- Clone the repo into your Ubuntu instance
- Run
kubectl apply -f murphy-movies.yaml
.- Test by running
kubectl get pods
, both murphy-movie pod should be inRUNNING
state andREADY (1/1)
. - If your pod is showing as
PENDING
, runkubectl describe <POD_NAME>
and inspect the lifecycle of the pod to debug further. - Run
kubectl logs <MURPHY_MOVIES_POD_NAME>
. If you see JDBC connection exceptions, you haven't configured MySQL properly. Check the username, password, user permissions for your MySQL user, database name. After fixing any errors, you runkubectl delete -f murphy-movies.yaml
and repeat Step 2.
- Test by running
- Run
kubectl apply -f ingress.yaml
. - Run
kubectl get ingress
to see your list of ingresses. - You should see an
ADDRESS
after a couple of minutes. You can then access the application on http://<AWS_ELB_URL>/cs122b-project5-murphy-movies. - You can also test whether sticky sessions work by inspecting cookies to find
stickounet
cookie. This cookie is used for identifying which pod your request will be routed to.