Categorygithub.com/guobinqiu/appdeployer
repositorypackage
0.0.0-20240926101124-cc1875dcd965
Repository: https://github.com/guobinqiu/appdeployer.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Quick Deployment of Applications to Kubernetes or VM Clusters

Parameter Description

Default Parameters

ParameterDescriptionRequiredDefault Value
appdirLocal project directoryYes
appnameApplication nameNoDirectory name

Git Parameters

ParameterDescriptionRequiredDefault Value
enabledWhether to pull the project from git to the specified local appdirNofalse
repoRepository nameenabled=true
usernameGit usernameenabled=true
passwordGit passwordenabled=true

SSH Parameters

ParameterDescriptionRequiredDefault Value
usernameSSH usernameYes
passwordSSH user passwordYes
portSSH portNo22
authorized_keys_pathPath to where the authorized_keys file generated on the SSH server storing SSH client's public keysNo~/.ssh/authorized_keys
privatekey_pathPath to where the private key file generated on the SSH clientNo~/.ssh/appdeployer
publickey_pathPath to where the public key file generated on the SSH clientNo~/.ssh/appdeployer.pub
knownhosts_pathPath to where the known_hosts file generated on the SSH client storing SSH server's public keysNo~/.ssh/known_hosts
stricthostkeycheckingSSH client verifies the server's public key before establishing a connectionNofalse

Ansible Parameters

ParameterDescriptionRequiredDefault Value
hostsList of remote machinesYeslocalhost, separate multiple hosts with commas, supports wildcards
roleApplication typeYesSupported types: go, java, nodejs
become_passwordPassword for sudo executionYes
installdirInstallation directory on remote machinesNo~/workspace

Docker Parameters

ParameterDescriptionRequiredDefault Value
dockerconfigPath to Docker's config file, usually located in the user's home directory under .docker/config.jsonNo~/.docker/config.json
dockerfilePath to the Dockerfile, which describes how to build the Docker image. Defaults to the root directoryNo./Dockerfile
registryURL of the Docker registry for pushing or pulling Docker images. Defaults to Docker Hub's official registryNohttps://index.docker.io/v1/
usernameUsername for accessing the Docker registry. Required if the registry requires authenticationYes
passwordPassword or access token corresponding to the username. Required if the registry requires authenticationYes
repositoryName of the Docker image repository, including the namespace if applicable (e.g., username/repository)Yes
tagTag of the Docker image to distinguish different versions or builds in the same repositoryNolatest

Kube Parameters

ParameterDescriptionRequiredDefault Value
kubeconfigPath to the Kubernetes cluster config file, used for interacting with the cluster.No~/.kube/config
namespaceNamespace in Kubernetes for resource isolationNoSame as default.appname
ingress.hostDomain or IP address for the Ingress resource to access the serviceNoappName + ".com"
ingress.tlsWhether to enable TLS encryptionNofalse
ingress.selfsignedWhether to use a self-signed certificateNofalse
ingress.selfsignedyearsValid years for the self-signed certificateNo1
ingress.crtpathPath to the custom TLS certificate (.crt file)No
ingress.keypathPath to the custom TLS key (.key file)No
service.portPort number exposed by the ServiceNo8000
deployment.replicasNumber of replicas in the DeploymentNo1
deployment.portPort number the application listens to inside the containerNo8000
deployment.rollingupdate.maxsurgeMaximum number of additional replicas allowed during rolling updatesNo1
deployment.rollingUpdate.maxunavailableMaximum number of unavailable replicas during rolling updatesNo0
deployment.quota.cpulimitCPU limit for the containerNo1000m
deployment.quota.memlimitMemory limit for the containerNo512Mi
deployment.quota.cpurequestCPU request for the containerNo500m
deployment.quota.memrequestMemory request for the containerNo256Mi
deployment.livenessprobe.enabledWhether to enable the liveness probeNofalse
deployment.livenessprobe.typeType of liveness probe (httpget, exec, tcpsocket), case insensitiveNohttpget
deployment.livenessprobe.pathHTTP path for the liveness probeNo/
deployment.livenessprobe.schemeHTTP scheme for the liveness probe (http, https), case insensitiveNohttp
deployment.livenessprobe.commandCommand for the liveness probe (used when type is exec)No
deployment.livenessprobe.initialdelaysecondsInitial delay in seconds for the liveness probeNo0
deployment.livenessprobe.timeoutsecondsTimeout in seconds for the liveness probeNo1
deployment.livenessprobe.periodsecondsCheck interval in seconds for the liveness probeNo10
deployment.livenessprobe.successthresholdSuccess threshold for the liveness probeNo1
deployment.livenessprobe.failurethresholdFailure threshold for the liveness probeNo3
deployment.readinessprobe.enabledWhether to enable the readiness probeNofalse
deployment.readinessprobe.typeType of readiness probe (httpget, exec, tcpsocket), case insensitiveNohttpget
deployment.readinessprobe.pathHTTP path for the readiness probeNo/
deployment.readinessprobe.schemeHTTP scheme for the readiness probe (http, https), case insensitiveNohttp
deployment.readinessprobe.commandCommand for the readiness probe (used when type is exec)No
deployment.readinessprobe.initialdelaysecondsInitial delay in seconds for the readiness probeNo0
deployment.readinessprobe.timeoutsecondsTimeout in seconds for the readiness probeNo1
deployment.readinessprobe.periodsecondsCheck interval in seconds for the readiness probeNo10
deployment.readinessprobe.successthresholdSuccess threshold for the readiness probeNo1
deployment.readinessprobe.failurethresholdFailure threshold for the readiness probeNo3
deployment.volumemount.enabledWhether to enable volume mountNofalse
deployment.volumemount.mountpathVolume mount pathNo/app/data
hpa.enabledWhether to enable Horizontal Pod AutoscalerNofalse
hpa.minreplicasMinimum number of Pod replicas to scale down toNo1
hpa.maxreplicasMaximum number of Pod replicas to scale up toNo10
hpa.cpurate=50CPU utilization threshold for scaling PodNo50
pvc.accessmodeAccess mode for PVC (readwriteonce, readonlymany, readwritemany), case insensitiveNoreadwriteonce
pvc.storageclassnameStorageClass used by the PVCNoopenebs-hostpath
pvc.storagesizeRequested storage size for the PVCNo1Gi

Usage

1. Web UI

https://github.com/guobinqiu/appdeployer-webui

2. CLI

Deploy to Kubernetes Cluster

go run main.go kube --default.appdir=~/workspace/hellogo --docker.username=qiuguobin --docker.password=*** --kube.kubeconfig=~/Downloads/config -e TZ=Asia/Shanghai

go run main.go kube --default.appdir=~/workspace/hellojava --docker.username=qiuguobin --docker.password=*** --kube.kubeconfig=~/Downloads/config -e TZ=Asia/Shanghai

go run main.go kube --default.appdir=~/workspace/hellonode --docker.username=qiuguobin --docker.password=*** --kube.kubeconfig=~/Downloads/config -e TZ=Asia/Shanghai

Deploy to VM Cluster

go run main.go vm --default.appdir=~/workspace/hellogo --ssh.username=guobin --ssh.password=111111 --ansible.become_password=111111 --ansible.hosts=192.168.1.9 --ansible.role=go

go run main.go vm --default.appdir=~/workspace/hellojava --ssh.username=guobin --ssh.password=111111 --ansible.become_password=111111 --ansible.hosts=192.168.1.9 --ansible.role=java

go run main.go vm --default.appdir=~/workspace/hellonode --ssh.username=guobin --ssh.password=111111 --ansible.become_password=111111 --ansible.hosts=192.168.1.9 --ansible.role=nodejs

3. API

Deploy to Kubernetes Cluster

curl --location 'http://localhost:8888/kube/submit' \
--header 'Content-Type: application/json' \
--data '{
    "default": {
        "appdir": "~/workspace/hellogo"
    },
    "docker": {
        "username": "qiuguobin",
        "password": "111111111"
    }
}'

curl -X GET 'http://localhost:8888/kube/deploy?requestID=XXXXXXXXXXX'

Deploy to VM Cluster

curl --location 'http://localhost:8888/vm/submit' \
--header 'Content-Type: application/json' \
--data '{
    "default": {
        "appdir": "~/workspace/hellogo"
    },
    "ssh": {
        "username": "guobin",
        "password": "111111"
    },
    "ansible": {
        "role": "go",
        "become_password": "111111",
        "hosts": "192.168.1.9"
    }
}'

curl -X GET 'http://localhost:8888/vm/deploy?requestID=XXXXXXXXXXX'

Todo List

  • Add label to Deployment for traffic distribution
  • Select multiple environments for simultaneous deployment
  • Add static code analysis
  • Add username and password login to the web UI
  • Retain the history of each deployment
  • ...