.. _deploy_service: Deploying a Service =================== In order to run ``k9 deploy service`` users must complete some set up beforehand. 1. Set up a helm repository with your application's helm chart. 2. Edit app-config.yml, k9-helm-values.yml, and helm-values.yml in the application directory. Edit defaults.yml in the ``k9/apps`` 3. (Optional) Create AWS secrets for the deployments. 4. Run ``k9 deploy service`` Helm Setup ---------- k9 uses helm for deployments and must be able to run ``helm repo add`` and ``helm install``. Users must manually create a helm repository, or add their chart to an existing repository. File Editing ------------ app-config.yml ************** See app-config.yml instructions here: :ref:`app-config` k9-helm-values.yml ****************** :: repoUrl: repoName: chartName: These values are simply what you would use when installing your helm chart manually. ``helm repo add repoName repoUrl`` ``helm install repoName/chartName`` defaults.yml ************ :: jenkins: jenkinsUrl: clusterName: clusters: - clusterName: np useBlueGreen: False - clusterName: prd useBlueGreen: True This file is used by all applications to set up jobs on jenkins. ``k9 create cicd`` will edit the jenkins section automatically. The clusters section may be updated to change which clusters should use blue-green deployment for the service deployments. helm-values.yml *************** Fill this file with any information your helm chart supports in the values.yml file. The contents of this file will be copied exactly into all the generated yaml files used when running helm install. Create AWS Secrets ------------------ As part of ``k9 deploy service`` AWS secrets will be read and turned into kubernetes secrets. Users may define a secret in AWS named ``{env}-{appName}-secret`` or ``{env}-{appName}-{customer}-secret`` if the deployment is for a particular customer. k9 will read or create an empty AWS secret for each deployment instance, and then place the secret values into a kubernetes secret in each namespace. Deploy Service -------------- :: k9 deploy service Run this command from your application directory. k9 will create a yaml file in the ``values/`` directory for each deployment defined in app-config.yml. This file will be the combination of helm-values.yml and a ``k9`` section full of helm information taken from k9-helm-values.yml. Extra values will be automatically added as well, to support blue-green deployment. Inside of each file there will be a k9 section filled in. :: # empty example k9: chartName: repoName: repoUrl: namespace: releaseName: The values here will be used to deploy the application to the correct namespace. In addition to deploying your app, ``k9 deploy service`` will - create an ECR in AWS - turn AWS application secrets from app-config.yml into kubernetes secrets in each deployment namespace - create a multibranch pipeline in jenkins linked to your git repository prd Flag ************ This command can be run with a ``prd`` flag when the production environment exists in a different account than the non-production deployment. In order to run ``k9 deploy service -prd`` users must complete some extra steps. 1. Create a prd-app-config.yml file by running ``k9 create prd-configs`` 2. Edit prd-app-config.yml in the application directory. 3. Edit ecr-sync-values.yml with the non-production account information. 3. Run ``k9 deploy service -prd``