mirror of
https://gitee.com/devstar/devstar-devcontainer-operator
synced 2025-04-21 09:42:22 +00:00
[feature] git clone repo upon initialization
Some checks failed
DevStar DevContainer Operator CI Pipeline - main branch / build-and-push-devstar-devcontainer-operator (push) Failing after 1m8s
Some checks failed
DevStar DevContainer Operator CI Pipeline - main branch / build-and-push-devstar-devcontainer-operator (push) Failing after 1m8s
This commit is contained in:
parent
50e6da3137
commit
b81c895162
@ -65,6 +65,8 @@ type StatefulSetSpec struct {
|
|||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
Command []string `json:"command"`
|
Command []string `json:"command"`
|
||||||
|
|
||||||
|
GitRepositoryURL string `json:"gitRepositoryURL"`
|
||||||
|
|
||||||
// +kubebuilder:validation:MinItems=1
|
// +kubebuilder:validation:MinItems=1
|
||||||
// 至少包含一个 SSH Public Key 才能通过校验规则
|
// 至少包含一个 SSH Public Key 才能通过校验规则
|
||||||
SSHPublicKeyList []string `json:"sshPublicKeyList"`
|
SSHPublicKeyList []string `json:"sshPublicKeyList"`
|
||||||
|
@ -74,6 +74,8 @@ spec:
|
|||||||
containerPort:
|
containerPort:
|
||||||
minimum: 1
|
minimum: 1
|
||||||
type: integer
|
type: integer
|
||||||
|
gitRepositoryURL:
|
||||||
|
type: string
|
||||||
image:
|
image:
|
||||||
type: string
|
type: string
|
||||||
sshPublicKeyList:
|
sshPublicKeyList:
|
||||||
@ -84,6 +86,7 @@ spec:
|
|||||||
type: array
|
type: array
|
||||||
required:
|
required:
|
||||||
- command
|
- command
|
||||||
|
- gitRepositoryURL
|
||||||
- image
|
- image
|
||||||
- sshPublicKeyList
|
- sshPublicKeyList
|
||||||
type: object
|
type: object
|
||||||
|
@ -8,11 +8,12 @@ metadata:
|
|||||||
app.kubernetes.io/managed-by: kustomize
|
app.kubernetes.io/managed-by: kustomize
|
||||||
spec:
|
spec:
|
||||||
statefulset:
|
statefulset:
|
||||||
image: mcr.microsoft.com/devcontainers/base:dev-ubuntu-20.04
|
image: devstar.cn/public/base-ssh-devcontainer:ubuntu-20.04-20241014
|
||||||
|
gitRepositoryURL: https://gitee.com/daimingchen_gitee/mock-repo
|
||||||
command:
|
command:
|
||||||
- /bin/bash
|
- /bin/bash
|
||||||
- -c
|
- -c
|
||||||
- apt-get update && apt-get install -y openssh-server && service ssh start && apt-get clean && tail -f /dev/null
|
- tail -f /dev/null
|
||||||
containerPort: 22
|
containerPort: 22
|
||||||
sshPublicKeyList:
|
sshPublicKeyList:
|
||||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC7TXcmW9GNAUou+s1PgBcJlZkw0xZ1ZxLktfsVKvsllYhpjYL7CTgUkl+t5GCvUdBvjQkoOGjenHj7VO3fkF43cFWsHPgBqIFMNDCXHfafbw7OCaKSyPb1Bn+y4mypoYhSy6YirGKSnC/Vw32VK9rtGpBuQse6KvJCMq34wOmdt7Em1vWYWxZaAkDNYUjrmY6/7bjSgUYWNlHx/kM8YQ4gluuackotAHaDo1owCK9dc9FZX2XUZcCJZVVRxCr0LRiyQqfO4s/YIUAetDmE0PP/FKc6lotRZGoNS9t1XSrMRVApF8V2+IgWNDMIzqtap/waMSNhSAOZtiyzx/VjLk92Bm8LPYpv3M1gsoQBZlp1lKstxDjhApq/H5pHOFVNGWPGW4rW5XB8F+Yrwg1PUvV/rBolG73BUAQF+V9UpV4SGKRZtzcOyTPwVZYJx9M5zF6NKAi5Dw8HXqDEvm/r6xc2Ak47NCfikdE3Szd4FZHUJrMY24bv1W4eiON7hHul8e8= TempSessionSSHPublicKey
|
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC7TXcmW9GNAUou+s1PgBcJlZkw0xZ1ZxLktfsVKvsllYhpjYL7CTgUkl+t5GCvUdBvjQkoOGjenHj7VO3fkF43cFWsHPgBqIFMNDCXHfafbw7OCaKSyPb1Bn+y4mypoYhSy6YirGKSnC/Vw32VK9rtGpBuQse6KvJCMq34wOmdt7Em1vWYWxZaAkDNYUjrmY6/7bjSgUYWNlHx/kM8YQ4gluuackotAHaDo1owCK9dc9FZX2XUZcCJZVVRxCr0LRiyQqfO4s/YIUAetDmE0PP/FKc6lotRZGoNS9t1XSrMRVApF8V2+IgWNDMIzqtap/waMSNhSAOZtiyzx/VjLk92Bm8LPYpv3M1gsoQBZlp1lKstxDjhApq/H5pHOFVNGWPGW4rW5XB8F+Yrwg1PUvV/rBolG73BUAQF+V9UpV4SGKRZtzcOyTPwVZYJx9M5zF6NKAi5Dw8HXqDEvm/r6xc2Ak47NCfikdE3Szd4FZHUJrMY24bv1W4eiON7hHul8e8= TempSessionSSHPublicKey
|
||||||
|
@ -97,11 +97,11 @@ func (r *DevcontainerAppReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
|||||||
}
|
}
|
||||||
logger.Info("DevContainer is READY", "ReadyReplicas", statefulSetInNamespace.Status.ReadyReplicas)
|
logger.Info("DevContainer is READY", "ReadyReplicas", statefulSetInNamespace.Status.ReadyReplicas)
|
||||||
} else {
|
} else {
|
||||||
app.Status.Ready = false
|
// app.Status.Ready = false
|
||||||
if err := r.Status().Update(ctx, app); err != nil {
|
// if err := r.Status().Update(ctx, app); err != nil {
|
||||||
logger.Error(err, "Failed to un-mark DevcontainerApp.Status.Ready", "DevcontainerApp.Status.Ready", app.Status.Ready)
|
// logger.Error(err, "Failed to un-mark DevcontainerApp.Status.Ready", "DevcontainerApp.Status.Ready", app.Status.Ready)
|
||||||
return ctrl.Result{}, err
|
// return ctrl.Result{}, err
|
||||||
}
|
// }
|
||||||
logger.Info("DevContainer is NOT ready", "ReadyReplicas", statefulSetInNamespace.Status.ReadyReplicas)
|
logger.Info("DevContainer is NOT ready", "ReadyReplicas", statefulSetInNamespace.Status.ReadyReplicas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ spec:
|
|||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: init-root-ssh-dir
|
- name: init-root-ssh-dir
|
||||||
image: {{.Spec.StatefulSet.Image}}
|
image: devstar.cn/public/busybox:27a71e19c956
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
@ -36,6 +36,16 @@ spec:
|
|||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: root-ssh-dir
|
- name: root-ssh-dir
|
||||||
mountPath: /root/.ssh
|
mountPath: /root/.ssh
|
||||||
|
- name: init-git-repo-dir
|
||||||
|
image: {{.Spec.StatefulSet.Image}}
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- if [ ! -d '/data/workspace' ]; then git clone {{.Spec.StatefulSet.GitRepositoryURL}} /data/workspace && echo "Git Repository cloned."; else echo "Folder already exists."; fi
|
||||||
|
volumeMounts:
|
||||||
|
- name: pvc-devcontainer
|
||||||
|
mountPath: /data
|
||||||
containers:
|
containers:
|
||||||
- name: {{.ObjectMeta.Name}}
|
- name: {{.ObjectMeta.Name}}
|
||||||
image: {{.Spec.StatefulSet.Image}}
|
image: {{.Spec.StatefulSet.Image}}
|
||||||
@ -61,7 +71,7 @@ spec:
|
|||||||
- -c
|
- -c
|
||||||
- exec ls ~
|
- exec ls ~
|
||||||
failureThreshold: 6
|
failureThreshold: 6
|
||||||
initialDelaySeconds: 10
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
successThreshold: 1
|
successThreshold: 1
|
||||||
timeoutSeconds: 5
|
timeoutSeconds: 5
|
||||||
@ -72,7 +82,7 @@ spec:
|
|||||||
- -c
|
- -c
|
||||||
- exec cat /etc/ssh/ssh_host*.pub
|
- exec cat /etc/ssh/ssh_host*.pub
|
||||||
failureThreshold: 6
|
failureThreshold: 6
|
||||||
initialDelaySeconds: 10
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
successThreshold: 1
|
successThreshold: 1
|
||||||
timeoutSeconds: 5
|
timeoutSeconds: 5
|
||||||
|
Loading…
Reference in New Issue
Block a user