AcalephStorage / kontinuous

The Kubernetes Continuous Integration & Delivery Platform (CI/CD) :arrows_counterclockwise:
Apache License 2.0
116 stars 9 forks source link

Stage: Deploy Improvements #43

Open hunter opened 8 years ago

hunter commented 8 years ago

The deploy stage is a good start but there are some improvements needed to be useful for real deployments.

Perhaps it is easier to use kubectl directly for the stage instead of the API

A few of these ideas are coming from the GCE CD Jenkins example (https://github.com/GoogleCloudPlatform/continuous-deployment-on-kubernetes/blob/master/sample-app/Jenkinsfile#L39-L48)

hunter commented 8 years ago

Helm uses a similar approach for their values/templates - https://github.com/kubernetes/helm/blob/master/docs/charts.md#templates-and-values

madziefe commented 8 years ago

For variables we can use gotemplate and toml to provide the values. we can add value_file or any better name for that? as param in deploy

      - name: Deploy App
        type: deploy
        params:
          deploy_file: manifest.yml
          value_file: manifest.toml

If value_file is left empty, then will run/apply manifest.yml as is.

hunter commented 8 years ago

A few alternatives to consider too...

KVs in the yaml:

      - name: Deploy App
        type: deploy
        params:
          deploy_file: manifest.yml
        vars:
          value1: something
          value2: somethingelse

or otherwise ConfigMaps

One consideration with any of these options is how do we handle/specify global variables (commit id, tags, etc) or pass vars them between stages

madziefe commented 8 years ago

for approach 1 these are the sample files:

manifest.yml

---
kind: Service
apiVersion: v1
metadata:
  name: {{.name}}
  namespace: {{default "kontinuous" .namespace}}

spec:
  selector:
    app: {{.name}}
    type: ci-cd
  ports:
    - name: api
      port: 8080
      targetPort: 8080
---
kind: Pod
apiVersion: v1
metadata:
  name: {{.name}}
  namespace: {{default "kontinuous" .namespace}}
  labels:
    app: {{.name}}
    type: ci-cd    
spec:
  containers:
    - name: {{.name}}
      image: {{.imageRegistry}}/{{.imageName}}:{{.dockerTag}}
      imagePullPolicy: {{.pullPolicy}}
      ports:
        - name: api
          containerPort: 8080
          protocol: TCP

manifest.toml

dockerTag = "latest"
pullPolicy = "Always"
name = "myproj"
namespace = "mayspace"
imageRegistry = "quay.io/myrepo"
imageName = "myprojimage"
madziefe commented 8 years ago

we can add globalvars in definition.yml to cater global variables and localvars for stage specific variables. In case a localvars key has the same key in globalvars, we'll use that localvars key for that stage.

hunter commented 8 years ago

Opened PR #53 for discussions...

madziefe commented 8 years ago

initial list of Kontinuous variables to be exposed to the user

        "KONTINUOUS_PIPELINE_ID":         Generated UUID for pipeline
        "KONTINUOUS_BUILD_ID":            Current build number
        "KONTINUOUS_STAGE_ID":            Curren stage number
        "KONTINUOUS_BRANCH":              Build Branch
        "KONTINUOUS_NAMESPACE":           Namespace defined in the .pipeline.yml
        "KONTINUOUS_ARTIFACT_URL":        Artifact path specified by user,
        "KONTINUOUS_REQUIRE_SOURCE_CODE": Always set to "TRUE".
        "KONTINUOUS_INTERNAL_REGISTRY":   Used by kontinuous as its own registry. Default value from System env. INTERNAL_REGISTRY
        "KONTINUOUS_COMMIT":              The commit of the build
        "KONTINUOUS_URL":                 Current url of Kontinuous 
hunter commented 8 years ago

These will be keys of the pipeline vars and ENV vars?

"KONTINUOUS_REQUIRE_SOURCE_CODE" what does this do?

madziefe commented 8 years ago

it's use in the kontinuous agent to git clone source.

hunter commented 8 years ago

Why is it needed globally?

darkcrux commented 8 years ago

i don't think we'll be needing that soon.

madziefe commented 8 years ago

the list is just partial. we can cherry-pick on what would be useful to the user.

madziefe commented 8 years ago

Fixes #53 Added support for templated deployment manifest file/s Added support for templated pipeline yaml Added support for single file / directory for deployment resources

Added support for global and local vars

hunter commented 8 years ago

Does this also include the Kontinuous variables?

madziefe commented 8 years ago

yes.

hunter commented 8 years ago

LGTM!

darkcrux commented 8 years ago

can we close this?