Skip to content

Commit

Permalink
#158 Add documentation on k8s local cluster deployment & run (#164)
Browse files Browse the repository at this point in the history
* #158 Add documentation on k8s local cluster deployment & run

* Update pom.xml
  • Loading branch information
conorheffron authored Nov 29, 2024
1 parent 3984e64 commit ceb4cf5
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 3 deletions.
85 changes: 83 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
Personal website / portfolio [https://www.ironoc.net/](https://www.ironoc.net/)

## Tech Stack
Java 21 (LTS), Spring Boot 3.3, ReactJs 18, Maven 3.8, HTML5+CSS, Docker / Bash, AWS
Java 21 (LTS), Spring Boot 3.3, ReactJs 18, Maven 3.8, HTML5+CSS,
Docker / Bash, AWS, minikube, & kubectl.

## Run without cloning project:
```
Expand All @@ -27,7 +28,13 @@ docker run -d --restart=always -p 8080:8080 conorheffron/ironoc
## Run after project checkout (JDK 21 & Maven 3.8.3 required)
Build / Run App:
```
mvn clean package spring-boot:run
mvn clean package
mvn -DAWS_ACCESS_KEY_ID=<val1> \
-DAWS_REGION=<val2> \
-DAWS_SECRET_ACCESS_KEY=<val3> \
-DAWS_SESSION_TOKEN=<val4> \
spring-boot:run
```

![image](screen-grabs/IDEA-Intellj-run.png)
Expand All @@ -51,4 +58,78 @@ docker-compose down
# Screenshot
![Home](screen-grabs/home-page.png)

# Local k8s cluster with Minikube:

MiniKube Install Notes for mac users
```
brew install kubectl
brew install virtualbox
brew install minikube
```

```
Oracle VirtualBox Manager v7.1.4
% kubectl version
Client Version: v1.30.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.31.0
% minikube version
minikube version: v1.34.0
commit: 210b148df93a80eb872ecbeb7e35281b3c582c61
% docker version
Client:
Version: 27.3.1
API version: 1.47
Go version: go1.22.7
Git commit: ce12230
Built: Fri Sep 20 11:38:18 2024
OS/Arch: darwin/amd64
Context: desktop-linux
```

- Open terminal
```
cd k8s/
# (clean-up & again after local testing complete)
minikube delete
minikube start --driver=docker
kubectl cluster-info
minikube dashboard
```

### Then change namespace in browser from default to ironoc-ns
- i.e. http://127.0.0.1:56414/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/pod?namespace=ironoc-ns

### Open New tab in terminal & create deployment
```
docker image build -t ironoc .
minikube image load ironoc:latest
kubectl create ns ironoc-ns
kubectl apply -f k8s/ironoc.yaml --namespace=ironoc-ns
kubectl get pods --namespace=ironoc-ns
kubectl get deployment --namespace=ironoc-ns
kubectl expose deployment ironoc-app-deployment --type=NodePort --namespace=ironoc-ns
kubectl get svc --namespace=ironoc-ns
minikube service ironoc-app-deployment --url --namespace=ironoc-ns
```

### Open New tab in terminal & tail logs
```
% kubectl get pods --namespace=ironoc-ns
NAME READY STATUS RESTARTS AGE
ironoc-app-deployment-6d84f75b44-kpqpj 1/1 Running 0 3m37s
kubectl logs ironoc-app-deployment-6d84f75b44-kpqpj -f --namespace=ironoc-ns
```
207 changes: 207 additions & 0 deletions k8s/ironoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ironoc-app-deployment
managedFields:
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
'f:spec':
'f:replicas': {}
manager: vpa-recommender
operation: Update
subresource: scale
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:labels':
.: {}
'f:app': {}
'f:spec':
'f:progressDeadlineSeconds': {}
'f:revisionHistoryLimit': {}
'f:selector': {}
'f:strategy':
'f:rollingUpdate':
.: {}
'f:maxSurge': {}
'f:maxUnavailable': {}
'f:type': {}
'f:template':
'f:metadata':
'f:labels':
.: {}
'f:app': {}
'f:spec':
'f:containers':
'k:{"name":"ironoc-app-sha256-1"}':
.: {}
'f:image': {}
'f:imagePullPolicy': {}
'f:name': {}
'f:resources': {}
'f:terminationMessagePath': {}
'f:terminationMessagePolicy': {}
'f:dnsPolicy': {}
'f:restartPolicy': {}
'f:schedulerName': {}
'f:securityContext': {}
'f:terminationGracePeriodSeconds': {}
manager: unknown
operation: Update
time: '2024-10-15T11:53:53Z'
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:annotations':
'f:deployment.kubernetes.io/revision': {}
'f:status':
'f:availableReplicas': {}
'f:conditions':
.: {}
'k:{"type":"Available"}':
.: {}
'f:lastTransitionTime': {}
'f:lastUpdateTime': {}
'f:message': {}
'f:reason': {}
'f:status': {}
'f:type': {}
'k:{"type":"Progressing"}':
.: {}
'f:lastTransitionTime': {}
'f:lastUpdateTime': {}
'f:message': {}
'f:reason': {}
'f:status': {}
'f:type': {}
'f:observedGeneration': {}
'f:readyReplicas': {}
'f:replicas': {}
'f:unavailableReplicas': {}
'f:updatedReplicas': {}
manager: kube-controller-manager
operation: Update
subresource: status
time: '2024-10-15T12:04:58Z'
name: ironoc-app-deployment
namespace: ironoc-ns
spec:
replicas: 1
selector:
matchLabels:
app: ironoc-app-deployment
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: ironoc-app-deployment
spec:
containers:
- image: ironoc:latest
imagePullPolicy: Never
ports:
- containerPort: 8080
name: ironoc-app-sha256-1
resources:
limits:
ephemeral-storage: 1Gi
requests:
cpu: 500m
ephemeral-storage: 1Gi
memory: 2Gi
securityContext:
capabilities:
drop:
- NET_RAW
securityContext:
seccompProfile:
type: RuntimeDefault
tolerations:
- effect: NoSchedule
key: kubernetes.io/arch
operator: Equal
value: amd64
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
labels:
app: ironoc-app-deployment
managedFields:
- apiVersion: autoscaling/v2
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:labels':
.: {}
'f:app': {}
'f:spec':
'f:maxReplicas': {}
'f:metrics': {}
'f:minReplicas': {}
'f:scaleTargetRef':
'f:apiVersion': {}
'f:kind': {}
'f:name': {}
manager: unknown
operation: Update
time: '2024-10-15T11:53:54Z'
- apiVersion: autoscaling/v2
fieldsType: FieldsV1
fieldsV1:
'f:status':
'f:conditions':
.: {}
'k:{"type":"AbleToScale"}':
.: {}
'f:lastTransitionTime': {}
'f:message': {}
'f:reason': {}
'f:status': {}
'f:type': {}
'k:{"type":"ScalingActive"}':
.: {}
'f:lastTransitionTime': {}
'f:message': {}
'f:reason': {}
'f:status': {}
'f:type': {}
'k:{"type":"ScalingLimited"}':
.: {}
'f:lastTransitionTime': {}
'f:message': {}
'f:reason': {}
'f:status': {}
'f:type': {}
'f:currentMetrics': {}
'f:currentReplicas': {}
'f:desiredReplicas': {}
'f:lastScaleTime': {}
manager: vpa-recommender
operation: Update
subresource: status
time: '2024-10-15T12:03:57Z'
name: ironoc-app-deployment-hpa-kbij
namespace: ironoc-ns
spec:
maxReplicas: 1
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ironoc-app-deployment
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>conorheffron</groupId>
<artifactId>ironoc</artifactId>
<version>5.2.12</version>
<version>5.3.1</version>
<packaging>war</packaging>

<distributionManagement>
Expand Down

0 comments on commit ceb4cf5

Please sign in to comment.