Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
---
apiVersion: v1
kind: Service
metadata:
name: code-server
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: code-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: code-server
name: code-server
spec:
selector:
matchLabels:
app: code-server
replicas: 1
template:
metadata:
labels:
app: code-server
spec:
initContainers:
# This container clones the desired git repo to the pvc volume.
- name: git-clone
image: jasonmorgan/code-server # using my code-server container as it already has the user and tools I need.
command:
- bash
args:
- /home/coder/prep.sh # Run the prep script from our configmap
volumeMounts:
- name: code-server-pv-claim
mountPath: /home/coder/
- name: prep-script
mountPath: /home/coder/prep.sh
subPath: prep.sh
env:
- name: REPO
value: https://github.com/JasonMorgan/code-server-getting-started.git
containers:
- image: jasonmorgan/code-server
imagePullPolicy: Always
name: code-server
args: ["/home/coder/projects/"]
env:
- name: PASSWORD
value: "some-password-you'll-remember"
- name: PORT
value: "8080"
volumeMounts:
- name: code-server-pv-claim
mountPath: /home/coder/
volumes:
- name: code-server-pv-claim
persistentVolumeClaim:
claimName: code-server-pv-claim
- name: prep-script
configMap:
name: prep-script
defaultMode: 0744
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: code-server-pv-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prep-script
data:
prep.sh: |
#!/bin/bash
sudo chown -R coder:coder /home/coder/
mkdir projects
cd /home/coder/projects/
git clone $REPO || true