Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage: Deploy Improvements #43

Open
2 of 4 tasks
hunter opened this issue May 18, 2016 · 17 comments
Open
2 of 4 tasks

Stage: Deploy Improvements #43

hunter opened this issue May 18, 2016 · 17 comments

Comments

@hunter
Copy link
Contributor

hunter commented May 18, 2016

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

  • Variable support for updating a manifest before deployment (perhaps adding gotmpl support and/or a regex)
  • Deploy to different namespace (eg. <basenamespace>-staging or <basenamespace>-<commitid>). Regex/Variable support useful here too?
  • Image Tag handling - deploying the image built in an earlier stage. Another variable to be used in a template?
  • kubectl apply support - updating existing resources in place

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
Copy link
Contributor Author

hunter commented May 18, 2016

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

@madziefe
Copy link
Contributor

madziefe commented May 24, 2016

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
Copy link
Contributor Author

hunter commented May 24, 2016

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
Copy link
Contributor

madziefe commented May 24, 2016

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
Copy link
Contributor

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
Copy link
Contributor Author

hunter commented May 25, 2016

Opened PR #53 for discussions...

@hunter hunter added in progress and removed ready labels May 25, 2016
@madziefe
Copy link
Contributor

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
Copy link
Contributor Author

hunter commented May 30, 2016

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

"KONTINUOUS_REQUIRE_SOURCE_CODE" what does this do?

@madziefe
Copy link
Contributor

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

@hunter
Copy link
Contributor Author

hunter commented May 30, 2016

Why is it needed globally?

@darkcrux
Copy link
Collaborator

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

@madziefe
Copy link
Contributor

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

@madziefe
Copy link
Contributor

madziefe commented Jun 3, 2016

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

  • deploy_file for single file
  • deploy_dir for resource directory

Added support for global and local vars

@hunter
Copy link
Contributor Author

hunter commented Jun 3, 2016

Does this also include the Kontinuous variables?

@madziefe
Copy link
Contributor

madziefe commented Jun 3, 2016

yes.

@hunter
Copy link
Contributor Author

hunter commented Jun 3, 2016

LGTM!

@darkcrux
Copy link
Collaborator

can we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants