-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from shubhMaheshwari/main
Adding YAML files to run syncthing on Nautilus clusters
- Loading branch information
Showing
7 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: test-pod | ||
spec: | ||
containers: | ||
- name: mypod | ||
image: ubuntu | ||
resources: | ||
limits: | ||
memory: 100Mi | ||
cpu: 100m | ||
requests: | ||
memory: 100Mi | ||
cpu: 100m | ||
command: ["sh", "-c", "echo 'Im a new pod' && sleep infinity"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: sports-analytics-database | ||
spec: | ||
storageClassName: rook-cephfs-central | ||
accessModes: | ||
- ReadWriteMany | ||
resources: | ||
requests: | ||
storage: 30Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
namespace: spatiotemporal-decision-making | ||
name: syncthing-setup | ||
spec: | ||
template: | ||
spec: | ||
affinity: | ||
nodeAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 1 | ||
preference: | ||
matchExpressions: | ||
# - key: topology.kubernetes.io/region | ||
# operator: In | ||
# values: | ||
# - us-west | ||
- key: nautilus.io/group | ||
operator: In | ||
values: | ||
- ry | ||
|
||
containers: | ||
- name: shubh-container | ||
image: gitlab-registry.nrp-nautilus.io/prp/jupyter-stack/minimal | ||
command: | ||
- /bin/bash | ||
- -c | ||
args: | ||
- "echo 'Hello, World!'" | ||
|
||
resources: | ||
limits: | ||
memory: 20Gi | ||
cpu: 8 | ||
nvidia.com/gpu: "1" | ||
requests: | ||
memory: 15Gi | ||
cpu: 4 | ||
nvidia.com/gpu: "1" | ||
|
||
volumeMounts: | ||
- mountPath: /dev/shm | ||
name: dshm | ||
- mountPath: /vol | ||
name: sports-analytics-database | ||
|
||
tolerations: | ||
- key: "nautilus.io/ry-reservation" | ||
operator: "Equal" | ||
value: "true" | ||
effect: "NoSchedule" | ||
restartPolicy: Never | ||
|
||
volumes: | ||
- name: dshm | ||
emptyDir: | ||
medium: Memory | ||
- name: sports-analytics-database | ||
persistentVolumeClaim: | ||
claimName: sports-analytics-database | ||
backoffLimit: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Usage instructions | ||
# This script deploys Syncthing to a Kubernetes cluster to synchronize data between a local machine and a Kubernetes Pod. | ||
# It requires the DEVICE_ID environment variable to be set to the Syncthing device ID of the local machine. | ||
# | ||
# Usage: | ||
# export DEVICE_ID="your-device-id" | ||
# ./sync-data.sh | ||
|
||
# Check if DEVICE_ID is set | ||
if [ -z "$DEVICE_ID" ]; then | ||
echo "Error: DEVICE_ID environment variable is not set. Used by Syncthing to identify the master machine." | ||
echo "Set: export DEVICE_ID=\"your-device-id\"" | ||
exit 1 | ||
fi | ||
|
||
# Delete the existing Pod if it exists | ||
kubectl delete pod data-transfer-pod --ignore-not-found | ||
|
||
# Apply the ConfigMap | ||
kubectl apply -f sync-data/syncthing-config.yaml | ||
|
||
# Apply the Pod | ||
kubectl apply -f sync-data/syncthing-setup.yaml | ||
|
||
# Wait for the Pod to be running | ||
echo "Waiting for the Pod to be running..." | ||
sleep 20 | ||
|
||
# Check Pod status | ||
POD_STATUS=$(kubectl get pod data-transfer-pod -o jsonpath='{.status.phase}') | ||
if [ "$POD_STATUS" != "Running" ]; then | ||
echo "Error: Pod is not running. Current status=$POD_STATUS" | ||
echo "Describing the Pod..." | ||
kubectl describe pod data-transfer-pod | ||
echo "Fetching Pod logs..." | ||
kubectl logs data-transfer-pod | ||
exit 1 | ||
fi | ||
|
||
echo "Syncthing deployment complete." | ||
echo "To access the Syncthing web GUI, run the following command:" | ||
echo "kubectl port-forward pod/data-transfer-pod 32000:8384" | ||
echo "Then open your browser and go to http://localhost:32000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: syncthing-config | ||
data: | ||
config.xml: | | ||
<configuration version="30"> | ||
<folder id="MCS_DATA" label="MCS_DATA" path="/mnt/data/MCS_DATA" type="readwrite"> | ||
<filesystemType>basic</filesystemType> | ||
<device id="${DEVICE_ID}"/> | ||
</folder> | ||
<device id="${DEVICE_ID}" name="KubernetesPod" compression="metadata" introducer="false" skipIntroductionRemovals="false"> | ||
<address>dynamic</address> | ||
<paused>false</paused> | ||
<autoAcceptFolders>false</autoAcceptFolders> | ||
<maxSendKbps>0</maxSendKbps> | ||
<maxRecvKbps>0</maxRecvKbps> | ||
<maxRequestKiB>0</maxRequestKiB> | ||
<untrusted>false</untrusted> | ||
</device> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: syncthing-service # Exposes the Syncthing web GUI port. | ||
spec: | ||
selector: | ||
app: syncthing | ||
ports: | ||
- protocol: TCP | ||
port: 8384 | ||
targetPort: 8384 | ||
type: NodePort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: data-transfer-pod | ||
labels: | ||
app: syncthing | ||
spec: | ||
containers: | ||
- name: syncthing | ||
image: syncthing/syncthing:latest | ||
ports: | ||
- containerPort: 8384 # Syncthing web GUI port | ||
- containerPort: 22000 # Syncthing sync port | ||
- containerPort: 21027 # Syncthing discovery port | ||
env: | ||
- name: DEVICE_ID | ||
value: "${DEVICE_ID}" | ||
volumeMounts: | ||
- mountPath: /mnt/data | ||
name: sports-analytics-database | ||
- mountPath: /var/syncthing/config | ||
name: syncthing-config | ||
command: ["/bin/sh"] | ||
args: ["-c", "mkdir -p /mnt/data/MCS_DATA && /bin/syncthing -home=/var/syncthing/config"] | ||
volumes: | ||
- name: sports-analytics-database | ||
persistentVolumeClaim: | ||
claimName: sports-analytics-database | ||
- name: syncthing-config | ||
emptyDir: {} | ||
restartPolicy: Never |