cicd

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 15 Imported by: 0

README

deployment.yaml

  • 这里举例使用了单个文件,如果使用kustomize,则可以替换patch文件的内容
  • 如果使用helm部署,则可以不使用这种替换方式,因为helm支持命令传参来设置
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: #{AppName}
  name: #{AppName}
  namespace: #{Namepspace}
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: #{AppName}
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: #{AppName}
    spec:
      containers:
        - image: #{Image}
          imagePullPolicy: IfNotPresent
          name: app
          resources:
            limits:
              cpu: 1000m
              memory: 1Gi
            requests:
              cpu: 50m
              memory: 50Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      imagePullSecrets:
        - name: tcr-scq
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeLayOutSet           = "20060102150405.000"
	TxTcrHost               = "ccr.ccs.tencentyun.com"
	TxTcrNamespaceDevopsScq = "devops_scq"
	LocalBuildBaseDir       = "/data/devops/build/"
	GitlabCICDRepoAddr      = "ssh://git@gitlab.scq.com:522/devops/cicd.git"
	CICDRepoLocalPath       = "devops_cicd"
)
View Source
var (
	LocalDeployBaseDir = "/data/devops/deploy/"
)

Functions

func NewCmd

func NewCmd(name string, args ...string) *exec.Cmd

cmd with os.Strerr and os.Stdout

func ReplaceAllWithFile

func ReplaceAllWithFile(filePath string, oldString, newString string) error

replace func, generate by gpt4.0

Types

type ConfigCICD

type ConfigCICD struct {
	BuildHistoryReserve int
}

type DockerBuild

type DockerBuild struct {
	ProjectName      string `json:"project_name"`
	Group            string `json:"group"`
	RepoSSH          string `json:"repo_ssh"`
	ProjectLocalPath string `json:"-"`
	TimestampNowDir  string `json:"-"`
	WorkDir          string `json:"-"`
	Type             string `json:"project_type"`
	Env              string `json:"project_env"`
	Tag              string `json:"tag_or_branch"`
	Image            string `json:"-"`
}

use ~/.ssh/id_rsa as git repo private key

func NewDockerBuild

func NewDockerBuild(name, group, sshAddr, buildType, buildEnv, tagOrbranch string) *DockerBuild

first use Dockerfile of devops/cicd project.Dockerfile_<buildEnv> second use Dockerfile of devops/cicd project.Dokerfile third use Dockerfile of repo.Dockerfile

func (*DockerBuild) Build

func (d *DockerBuild) Build() gin.HandlerFunc

func (*DockerBuild) DoBuild

func (d *DockerBuild) DoBuild() error

func (*DockerBuild) DoClone

func (d *DockerBuild) DoClone(c ConfigCICD) error

clone

func (*DockerBuild) DoPush

func (d *DockerBuild) DoPush() error

push

func (*DockerBuild) SetAllPath

func (d *DockerBuild) SetAllPath()

type K8sDeploy

type K8sDeploy struct {
	AppName   string                `json:"app_name"`
	Group     string                `json:"group"`
	Namespace string                `josn:"namespace"`
	WorkDir   string                `json:"-"`
	Type      string                `json:"project_type"`
	Env       string                `json:"project_env"`
	Tag       string                `json:"tag_or_branch"`
	Image     string                `json:"-"`
	Client    *kubernetes.Clientset `json:"-"`
}

func NewK8sDeploy

func NewK8sDeploy(name, group, namespace, deployType, env, tag string) *K8sDeploy

func (*K8sDeploy) Deploy

func (k *K8sDeploy) Deploy() gin.HandlerFunc

gin handlefunc

func (*K8sDeploy) DoDeploy

func (k *K8sDeploy) DoDeploy() error

if found on k8s update image or depoly use devops/cicd project/deploy/ yaml files, like kustomize/helm/operator

func (*K8sDeploy) SetAll

func (k *K8sDeploy) SetAll()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL