mirror of
				https://gitee.com/devstar/devstar-devcontainer-operator
				synced 2025-11-02 03:40:34 +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:
		@@ -65,6 +65,8 @@ type StatefulSetSpec struct {
 | 
			
		||||
	Image   string   `json:"image"`
 | 
			
		||||
	Command []string `json:"command"`
 | 
			
		||||
 | 
			
		||||
	GitRepositoryURL string `json:"gitRepositoryURL"`
 | 
			
		||||
 | 
			
		||||
	// +kubebuilder:validation:MinItems=1
 | 
			
		||||
	// 至少包含一个 SSH Public Key 才能通过校验规则
 | 
			
		||||
	SSHPublicKeyList []string `json:"sshPublicKeyList"`
 | 
			
		||||
 
 | 
			
		||||
@@ -74,6 +74,8 @@ spec:
 | 
			
		||||
                  containerPort:
 | 
			
		||||
                    minimum: 1
 | 
			
		||||
                    type: integer
 | 
			
		||||
                  gitRepositoryURL:
 | 
			
		||||
                    type: string
 | 
			
		||||
                  image:
 | 
			
		||||
                    type: string
 | 
			
		||||
                  sshPublicKeyList:
 | 
			
		||||
@@ -84,6 +86,7 @@ spec:
 | 
			
		||||
                    type: array
 | 
			
		||||
                required:
 | 
			
		||||
                - command
 | 
			
		||||
                - gitRepositoryURL
 | 
			
		||||
                - image
 | 
			
		||||
                - sshPublicKeyList
 | 
			
		||||
                type: object
 | 
			
		||||
 
 | 
			
		||||
@@ -8,11 +8,12 @@ metadata:
 | 
			
		||||
    app.kubernetes.io/managed-by: kustomize
 | 
			
		||||
spec:
 | 
			
		||||
  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:
 | 
			
		||||
      - /bin/bash
 | 
			
		||||
      - -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
 | 
			
		||||
    sshPublicKeyList:
 | 
			
		||||
      - 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)
 | 
			
		||||
		} else {
 | 
			
		||||
			app.Status.Ready = false
 | 
			
		||||
			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)
 | 
			
		||||
				return ctrl.Result{}, err
 | 
			
		||||
			}
 | 
			
		||||
			// app.Status.Ready = false
 | 
			
		||||
			// 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)
 | 
			
		||||
			// 	return ctrl.Result{}, err
 | 
			
		||||
			// }
 | 
			
		||||
			logger.Info("DevContainer is NOT ready", "ReadyReplicas", statefulSetInNamespace.Status.ReadyReplicas)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ spec:
 | 
			
		||||
          emptyDir: {}
 | 
			
		||||
      initContainers:
 | 
			
		||||
        - name: init-root-ssh-dir
 | 
			
		||||
          image: {{.Spec.StatefulSet.Image}}
 | 
			
		||||
          image: devstar.cn/public/busybox:27a71e19c956
 | 
			
		||||
          imagePullPolicy: IfNotPresent
 | 
			
		||||
          command:
 | 
			
		||||
            - /bin/sh
 | 
			
		||||
@@ -36,6 +36,16 @@ spec:
 | 
			
		||||
          volumeMounts:
 | 
			
		||||
            - name: root-ssh-dir
 | 
			
		||||
              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:
 | 
			
		||||
        - name: {{.ObjectMeta.Name}}
 | 
			
		||||
          image: {{.Spec.StatefulSet.Image}}
 | 
			
		||||
@@ -61,7 +71,7 @@ spec:
 | 
			
		||||
              - -c
 | 
			
		||||
              - exec ls ~
 | 
			
		||||
            failureThreshold: 6
 | 
			
		||||
            initialDelaySeconds: 10
 | 
			
		||||
            initialDelaySeconds: 5
 | 
			
		||||
            periodSeconds: 10
 | 
			
		||||
            successThreshold: 1
 | 
			
		||||
            timeoutSeconds: 5
 | 
			
		||||
@@ -72,7 +82,7 @@ spec:
 | 
			
		||||
              - -c
 | 
			
		||||
              - exec cat /etc/ssh/ssh_host*.pub
 | 
			
		||||
            failureThreshold: 6
 | 
			
		||||
            initialDelaySeconds: 10
 | 
			
		||||
            initialDelaySeconds: 5
 | 
			
		||||
            periodSeconds: 10
 | 
			
		||||
            successThreshold: 1
 | 
			
		||||
            timeoutSeconds: 5
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user