Commit 93ab97ca authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'ci_template_cluster_applications' into 'master'

CI template for installing cluster applications

See merge request gitlab-org/gitlab!20822
parents 31c1e954 43b866e3
---
title: CI template for installing cluster applications
merge_request: 20822
author:
type: added
......@@ -429,6 +429,69 @@ administrator to run following command within a Rails console:
Feature.enable(:enable_cluster_application_crossplane)
```
## Install using GitLab CI (alpha)
> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/20822) in GitLab 12.6.
CAUTION: **Warning:**
This is an _alpha_ feature, and it is subject to change at any time without
prior notice.
This alternative method allows users to install GitLab-managed
applications using GitLab CI. It also allows customization of the
install using Helm `values.yaml` files.
Supported applications:
- [Ingress](#install-ingress-using-gitlab-ci)
### Usage
To install applications using GitLab CI:
1. Connect the cluster to a [cluster management project](management_project.md).
1. In that project, add a `.gitlab-ci.yml` file with the following content:
```yaml
include:
- template: Managed-Cluster-Applications.gitlab-ci.yml
```
1. Add a `.gitlab/managed-apps/config.yaml` file to define which
applications you would like to install. Define the `installed` key as
`true` to install the application and `false` to uninstall the
application. For example, to install Ingress:
```yaml
ingress:
installed: true
```
1. Optionally, define `.gitlab/managed-apps/<application>/values.yaml` file to
customize values for the installed application.
A GitLab CI pipeline will then run on the `master` branch to install the
applications you have configured.
### Install Ingress using GitLab CI
To install ingress, define the `.gitlab/managed-apps/config.yaml` file
with:
```yaml
ingress:
installed: true
```
Ingress will then be installed into the `gitlab-managed-apps` namespace
of your cluster.
You can customize the installation of Ingress by defining
`.gitlab/managed-apps/ingress/values.yaml` file in your cluster
management project. Refer to the
[chart](https://github.com/helm/charts/tree/master/stable/nginx-ingress)
for the available configuration options.
## Upgrading applications
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/24789) in GitLab 11.8.
......
apply:
stage: deploy
image: "registry.gitlab.com/gitlab-org/cluster-integration/cluster-applications:v0.1.0"
environment:
name: production
variables:
TILLER_NAMESPACE: gitlab-managed-apps
GITLAB_MANAGED_APPS_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/config.yaml
INGRESS_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/ingress/values.yaml
script:
- gitlab-managed-apps /usr/local/share/gitlab-managed-apps/helmfile.yaml
only:
refs:
- master
# frozen_string_literal: true
require 'spec_helper'
describe 'Managed-Cluster-Applications.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Managed-Cluster-Applications') }
describe 'the created pipeline' do
let_it_be(:user) { create(:user) }
let(:project) { create(:project, :custom_repo, namespace: user.namespace, files: { 'README.md' => '' }) }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_branch ) }
let(:pipeline) { service.execute!(:push) }
let(:build_names) { pipeline.builds.pluck(:name) }
let(:pipeline_branch) { 'master' }
before do
stub_ci_pipeline_yaml_file(template.content)
end
context 'for a default branch' do
it 'creates a apply job' do
expect(build_names).to match_array('apply')
end
end
context 'outside of default branch' do
let(:pipeline_branch) { 'a_branch' }
before do
project.repository.create_branch(pipeline_branch)
end
it 'has no jobs' do
expect { pipeline }.to raise_error(Ci::CreatePipelineService::CreateError, 'No stages / jobs for this pipeline.')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment