diff --git a/deploy.sh b/deploy.sh index 0fdc222..72ad8c4 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,28 +1,17 @@ #!/bin/bash -# Set variables -REGISTRY_URL="ghcr.io/biolytics-ai/k8s-dev-env" # Change this to your Docker registry URL -IMAGE_NAME="vscode-bastion-devcontainer" -IMAGE_TAG="latest" # or use $(git rev-parse --short HEAD) for git commit hash based tags -NAMESPACE="biolyticsai-dev" - -# Path to directories containing Kubernetes configs -K8S_CONFIG_PATH="." # Path where Kubernetes YAML files are located - -# Replace image name in the Kubernetes deployment file with the newly built image -echo "Updating Kubernetes deployment with new image..." -sed -i "s|your-registry/your-image-name:tag|$REGISTRY_URL/$IMAGE_NAME:$IMAGE_TAG|g" $K8S_CONFIG_PATH/dev-environment-deployment.yaml - # Apply Persistent Volume Claim (if needed) -# echo "Applying Persistent Volume Claim..." -# kubectl apply -f $K8S_CONFIG_PATH/dev-environment-pvc.yaml +echo "Applying Persistent Volume Claim..." +kubectl apply -f dev-environment-pvc.yaml # Apply Kubernetes deployment echo "Deploying to Kubernetes..." -kubectl apply -f $K8S_CONFIG_PATH/dev-environment-deployment.yaml +kubectl apply -f dev-environment-deployment.yaml # Apply Kubernetes service echo "Applying Kubernetes service..." -kubectl apply -f $K8S_CONFIG_PATH/dev-environment-service.yaml +kubectl apply -f dev-environment-service.yaml + +kubectl apply -f dev-environment-service-ingress.yml -echo "Deployment completed successfully!" +echo "Deployment completed successfully!" \ No newline at end of file diff --git a/dev-environment-deployment.yaml b/dev-environment-deployment.yaml index 4198a49..bb606ab 100644 --- a/dev-environment-deployment.yaml +++ b/dev-environment-deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: dev-environment + namespace: biolytics-dev # Match the PVC's namespace spec: replicas: 1 selector: @@ -17,3 +18,12 @@ spec: image: ghcr.io/biolytics-ai/k8s-dev-env/vscode-bastion-devcontainer:latest ports: - containerPort: 8080 + securityContext: + runAsUser: 0 + volumeMounts: + - name: vscode-data + mountPath: /data + volumes: + - name: vscode-data + persistentVolumeClaim: + claimName: dev-environment-pvc # Use the PVC here \ No newline at end of file diff --git a/dev-environment-pvc.yaml b/dev-environment-pvc.yaml index 1cdbef2..ffd0f0c 100644 --- a/dev-environment-pvc.yaml +++ b/dev-environment-pvc.yaml @@ -2,11 +2,11 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: dev-environment-pvc - namespace: biolyticsai-dev + namespace: biolytics-dev spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi - storageClassName: standard \ No newline at end of file + storageClassName: openebs-hostpath # or openebs-device diff --git a/dev-environment-service-ingress.yml b/dev-environment-service-ingress.yml new file mode 100644 index 0000000..5c85f46 --- /dev/null +++ b/dev-environment-service-ingress.yml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: dev-environment-ingress + namespace: biolytics-dev + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + rules: + - host: biolyticsai.ai.gerimedica.io + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: dev-environment-service + port: + number: 8080 diff --git a/dev-environment-service.yaml b/dev-environment-service.yaml index f54ed4e..de53b9b 100644 --- a/dev-environment-service.yaml +++ b/dev-environment-service.yaml @@ -1,12 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: dev-environment - namespace: biolyticsai-dev + name: dev-environment-service + namespace: biolytics-dev spec: type: ClusterIP ports: - port: 8080 targetPort: 8080 + protocol: TCP selector: app: dev-environment \ No newline at end of file diff --git a/readme.md b/readme.md index be0bd0b..b718ae9 100644 --- a/readme.md +++ b/readme.md @@ -119,3 +119,11 @@ This configuration ensures that sensitive credentials and configurations used to ## todo: Persistent Storage (Optional) For a more persistent setup, consider adding a Persistent Volume Claim (PVC) to your deployment to retain your workspace data across container restarts. + +# todo + + Configure gitlab-ci.yml to automate Docker builds and push to the Harbor registry. + Create and apply Kubernetes configuration files (dev-environment-deployment.yaml, dev-environment-service.yaml, dev-environment-pvc.yaml). + Document the process and configurations in readme.md to guide developers on how to connect and use the environment. + Ensure all Kubernetes configurations and Dockerfiles are committed and reviewed via a pull request. + Set up a Git strategy (submodules or scripts) that allows pushing code updates to both GitLab (using VPN) and GitHub to ensure that both repositories stay synchronized.