# Installing Autopilot

If you are already using Open Source Spinnaker, then Autopilot can get seamlessly integrated with your Open Source Spinnaker and you get the all the benefits of Autopilot product. The following section defines the procedure for installing Autopilot as a standalone module to work with Open Source Spinnaker.

{% hint style="info" %}
If you are installing Autopilot along with ISD, then refer the detailed installation procedure [here](https://docs.opsmx.com/opsmx-intelligent-software-delivery-platform/opsmx-isd-installation).&#x20;

Refer the below installation procedure **only if** you are installing Autopilot as an independent module and want to integrate it with Open Source Spinnaker
{% endhint %}

### Prerequisites

1. Have access to public repositories in docker.io and quay.io&#x20;
2. Have the following tools installed - wget, kubectl, helm&#x20;
3. Have access to a Kubernetes cluster with at least 2 nodes, each node having 8 CPU and 32 GB RAM&#x20;
4. Have the NGINX Ingress Controller installed in the cluster. If it is not already installation, then you can install the same using the following instructions &#x20;

   `$ kubectl create ns ingress-nginx`&#x20;

   `$ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx`&#x20;

   `$ helm repo update`&#x20;

   `$ helm install ingress-nginx ingress-nginx/ingress-nginx -n ingress-nginx`&#x20;

   `$ kubectl get svc -n ingress-nginx`
5. Have “cert-manager” already available in the cluster. If it is not already available, then you can install it using the following instructions

   `$ kubectl create namespace cert-manager`&#x20;

   `$ helm repo add jetstack https://charts.jetstack.io`&#x20;

   `$ helm repo update`&#x20;

   `$ helm install cert-manager jetstack/cert-manager --set installCRDs=true -n cert-manager`
6. In the Kubernetes cluster, have 3 Persistent Volumes of size 10GB each
7. Two DNS records pointing to the IP of the Ingress Controller for the following:&#x20;
   * “Autopilot UI”, Eg. autopilot.opsmx.net&#x20;
   * “Autopilot Gate”, Eg. autopilot-gate.opsmx.net

### Autopilot Installation Steps

Following are the steps to install Autopilot.

1. Download yaml file from the Enterprise Spinnaker repository in the GitHub

   `$ wget` [`https://raw.githubusercontent.com/OpsMx/enterprise-spinnaker/oes3.10/charts/oes/values-APforOSS.yaml`](https://raw.githubusercontent.com/OpsMx/enterprise-spinnaker/oes3.10/charts/oes/values-APforOSS.yaml)
2. Update Autopilot UI and Autopilot Gate entries

   `#Autopilot UI URL configuration`

   `oesUI:`&#x20;

   &#x20; `host: << AUTOPILOT UI URL Example autopilot.opsmx.net >>`

   `#Autopilot Gate URL configuration`

   `oesGate:`&#x20;

   &#x20; `host: << AUTOPILOT GATE URL Example autopilot-gate.opsmx.net >>`
3. Update Spinnaker Deck URL in dashboard section of values-APforOSS.yaml

   `#Dashboard Service`&#x20;

   `dashboard:`&#x20;

   &#x20; `config:`&#x20;

   &#x20;   `spinnakerLink: <<SPINNAKER DECK URL Example spinaker.opsmx.net>>`
4. Authentication:
   * **Using LDAP**

     Make changes in the ldap section in values-APforOSS.yaml

     `#ldap configuration used in oes-gate, oes-platform and spinnaker gate for authentication and authorization`

     `#Change the below settings based on your LDAP server`

     `Ldap:`&#x20;

     &#x20; `enabled: true`&#x20;

     &#x20; `url: << LDAP URL: Example: ldaps://xxx.opsmx.com:636 >>`&#x20;

     &#x20; `managerDn: cn=manager,dc=opsmx,dc=com`&#x20;

     &#x20; `managerPassword: manager123`&#x20;

     &#x20; `groupSearchBase: ou=groups,dc=opsmx,dc=com`&#x20;

     &#x20; `groupSearchFilter: member={0}`&#x20;

     &#x20; `groupRoleAttributes: cn`&#x20;

     &#x20; `userDnPattern: uid={0},ou=users,dc=opsmx,dc=com`

     ***Note**:*

     ***managerDn**: The Distinguished Name (DN) used to log into the Directory Service and to search for user accounts.*&#x20;

     ***manager-password**: The password for the manager account specified in the managerDn property.*&#x20;

     ***groupSearchBase**: The DN of the LDAP object where the search for the user account's groups begins.*&#x20;

     ***groupSearchFilter**: The LDAP query string used to find the user account's group objects. The default is “(member={0})”. (In some LDAP implementations the name is memberof.). The {0} is a required value. It is a token that represents the user account that is being validated*&#x20;

     ***groupRoleAttributes**: The field name to use as the Security role name for the group object DN*

     ***userDnPattern**: The field name to tell the authenticator how to find a user in LDAP*
   * **Using SAML 2.0**

     Make changes in the saml section in values-APforOSS.yaml

     `saml:`&#x20;

     &#x20; `enabled: true`

     &#x20; `userSource: gate # Groups will be obtained from SAML`&#x20;

     &#x20; `keyStore: /opt/spinnaker/saml/oessaml.jks # The key in this secret must be oessamljks`&#x20;

     &#x20; `keyStorePassword: changeit`&#x20;

     &#x20; `keyStoreAliasName: saml`&#x20;

     &#x20; `metadataUrl: /opt/spinnaker/saml/oesmetadata.xml # The key in this secret must be oesmetadataxml`&#x20;

     &#x20; `redirectProtocol: https`&#x20;

     &#x20; `redirectHostname: << AUTOPILOT GATE URL Example autopilot-gate.opsmx.net >>`&#x20;

     &#x20; `redirectBasePath: /`&#x20;

     &#x20; `issuerId: << Unique Issuer Id Example opsmx.test >>`&#x20;

     &#x20; `jksSecretName: oessamljks`&#x20;

     &#x20; `metadataSecretName: oesmetadataxml`
   * **Using OAuth 2.0**

     Autopilot supports OAuth 2.0 for authentication with GitHub organizations. Consult the GitHub OAuth 2.0 documentation and register a new OAuth 2.0 application to obtain a client ID and client secret. Make changes in the oauth2 section in values-APforOSS.yaml

     `oauth2:`&#x20;

     &#x20; `enabled: true`&#x20;

     &#x20; `client:`&#x20;

     &#x20;   `clientId: #CLIENT_ID`&#x20;

     &#x20;   `clientSecret: #CLIENT_SECRET_ID`&#x20;

     &#x20;   `accessTokenUri: https://github.com/login/oauth/access_token`&#x20;

     &#x20;   `userAuthorizationUri: https://github.com/login/oauth/authorize`&#x20;

     &#x20;   `scope: user-email`&#x20;

     &#x20; `resource:`&#x20;

     &#x20;   `userInfoUri: https://api.github.com/user`&#x20;

     &#x20; `userInfoMapping:`&#x20;

     `email: email`&#x20;

     &#x20;   `firstName: firstname`&#x20;

     &#x20;   `lastName: name`&#x20;

     &#x20;   `username: login`&#x20;

     &#x20; `provider: GITHUB`
5. Specify the user groups from the authentication system; these groups will have Super Administrator privileges in Autopilot. Specify userSource for the specific authorization type.

   `platform:`&#x20;

   &#x20; `config:`&#x20;

   &#x20;   `#These groups will have superAdmin privileges in Autopilot adminGroups: admin`

   &#x20;   `#Source of groups for Authorization`

   &#x20;   `#Support sources: LDAP, FILE, GATE. In general, use "gate" for SAML`

   &#x20;   `userSource: ldap`
6. Specify Spinnaker Gate URL. When the Authentication type is X509, set the corresponding flag to true.

   `sapor:`&#x20;

   &#x20; `config:`&#x20;

   &#x20;   `spinnakerImages: OSS`&#x20;

   &#x20;   `spinnaker:`&#x20;

   &#x20;   `#true if authentication is enabled in Spinnaker authnEnabled: true`&#x20;

   &#x20;   `#encryption key is needed for sapor to startup`&#x20;

   &#x20;   `encrupt:`&#x20;

   &#x20;     `enabled:false`
7. Add opsmx helm chart using the command

   `$ helm repo add opsmx https://helmcharts.opsmx.com/`&#x20;

   `$ helm repo update`

   Create a namespace for installing Autopilot&#x20;

   `$ kubectl create namespace autopilot`

   Begin the installation using the following command&#x20;

   `$ helm install myautopilot opsmx/oes -f values-APforOSS.yaml -n autopilot --timeout 60m`
8. Run the following command to get the URLs

   `$kubectl get ingress -n autopilot`&#x20;

   IP addresses should be linked to URLs in the DNS server

### Integrate Autopilot with Open Source Spinnaker

After installing Autopilot, there are few changes in your Open Source Spinnaker configuration to integrate it with Autopilot. Following are the changes:

1. Before editing yaml files in Spinnaker, first ensure their persistence. If they are not persistent already, follow these steps.

   *Example:*&#x20;

   `$ kubectl edit cm ossspin-spinnaker-halyard-init-script`&#x20;

   *Where ossspin is the name of the spinnaker instance. Change it as per your instance name. The following lines need to be commented out, followed by save.*&#x20;

   &#x20;`# rm -rf /tmp/spinnaker/.hal/default/service-settings`

   &#x20;`# cp /tmp/service-settings/*/tmp/spinnaker/.hal/default/service-settings`

   &#x20;`# rm -rf /tmp/spinnaker/.hal/default/profiles`

   &#x20;`# cp /tmp/additionalProfileConfigMaps/*/tmp/spinnaker/.hal/default/profiles/`
2. Enable echo events in OSS Spinnaker. Get a shell to the Spinnaker halyard pod.&#x20;

   Example:&#x20;

   `kubectl exec -it oes-spinnaker-halyard-0 -n oss-spin -- /bin/bash`&#x20;

   Go to location: `~/.hal/default/profiles` edit the file **echo-local.yml**;&#x20;

   Create a new file if not available&#x20;

   **$ vi echo-local.yml**&#x20;

   Update/Add the following lines, with the correct "Autopilot Gate" URL.

   &#x20;  `rest:`

   &#x20;    `enabled: true`

   &#x20;    `endpoints:`

   &#x20;      `-`

   &#x20;        `wrap: false`

   &#x20;        `url: << AUTOPILOT GATE URL`&#x20;

   &#x20;     *`Example https://autopilot-gate.opsmx.net >>/auditservice/v1/echo/events/data`*&#x20;

   &#x20;      `-`

   &#x20;        `wrap: false`

   &#x20;        `url: << AUTOPILOT GATE URL`

   &#x20;     *`Example https://autopilot-gate.opsmx.net >>/oes/echo`*
3. Enable Custom Plugins in Spinnaker. Get a shell to the Spinnaker halyard pod.

   *Example:*&#x20;

   *`$kubectl exec -it spinnaker-halyard-0 -n oss-spin -- /bin/bash`*&#x20;

   Go to location: *\~/.hal/default/profiles*&#x20;

   `$ cd ~/.hal/default/profiles`&#x20;

   Edit the file *orca-local.yml* (create a new file if not available)

   `$ vi orca-local.yml`&#x20;

   Update/Add the following lines

   &#x20; `spinnaker:`

   &#x20;   `extensibility:`

   &#x20;     `plugins:`

   &#x20;       `Opsmx.VerificationGatePlugin:`

   &#x20;         `enabled: true`

   &#x20;         `version: 1.0.1`

   &#x20;         `config:`

   &#x20;       `Opsmx.VisibilityApprovalPlugin:`

   &#x20;         `enabled: true`

   &#x20;         `version: 1.0.1`

   &#x20;         `config:`

   &#x20;       `Opsmx.TestVerificationGatePlugin:`

   &#x20;         `enabled: true`

   &#x20;         `version: 1.0.1`

   &#x20;         `config:`

   &#x20;       `Opsmx.PolicyGatePlugin:`

   &#x20;         `enabled: true`

   &#x20;         `version: 1.0.1`

   &#x20;         `config:`

   &#x20;     `repositories:`

   &#x20;       `opsmx-repo:`

   &#x20;         `id: opsmx-repo`

   &#x20;         `url:` [`https://raw.githubusercontent.com/OpsMx/spinnakerPluginRepository/v3.10.0/plugins.json`](https://raw.githubusercontent.com/OpsMx/spinnakerPluginRepository/v3.10.0/plugins.json)

   Edit the file *gate-local.yml* (create a new file if not available)

   `$ vi gate-local.yml`

   Update/add the following lines

   &#x20; `spinnaker:`

   &#x20;  `extensibility:`

   &#x20;     `plugins:`

   &#x20;     `deck-proxy:`

   &#x20;       `enabled: true`

   &#x20;       `plugins:`

   &#x20;         `Opsmx.VerificationGatePlugin:`

   &#x20;           `enabled: true`

   &#x20;           `version: 1.0.1`

   &#x20;         `Opsmx.TestVerificationGatePlugin:`

   &#x20;           `enabled: true`

   &#x20;           `version: 1.0.1`

   &#x20;         `Opsmx.PolicyGatePlugin:`

   &#x20;           `enabled: true`

   &#x20;           `version: 1.0.1`

   &#x20;         `Opsmx.VisibilityApprovalPlugin:`

   &#x20;           `enabled: true`

   &#x20;           `version: 1.0.1`

   &#x20;     `plugins-root-path: /opt/gate/plugins`

   &#x20;     `repositories:`

   &#x20;       `opsmx-repo:`

   &#x20;         `url: https://raw.githubusercontent.com/OpsMx/spinnakerPluginRepository/v3.10.0/plugins.json`

   Edit the file *front50-local.yml* (create a new file if not available)&#x20;

   `$ vi front50-local.yml`

   Update/add the following lines

   &#x20; `spinnaker:`

   &#x20;   `extensibility:`

   &#x20;     `plugins:`

   &#x20;       `Opsmx.StaticPolicyPlugin:`

   &#x20;         `enabled: true`

   &#x20;         `version: "1.0.1"`

   &#x20;         `config: null`

   &#x20;     `repositories:`

   &#x20;       `opsmx-repo:`

   &#x20;         `id: "opsmx-repo"`

   &#x20;         `url: "https://raw.githubusercontent.com/OpsMx/spinnakerPluginRepository/v3.10.0.staticpolicy/plugins.json"`&#x20;

   &#x20; `policy:`&#x20;

   &#x20;   `opa:`&#x20;

   &#x20;     `enabled: true`&#x20;

   &#x20;     `url: << AUTOPILOT GATE URL Example https://autopilot-gate.opsmx.net >>`
4. Run Hal deploy apply command to reflect the changes&#x20;

   `$ hal deploy apply`
5. Configure Spinnaker in Autopilot UI Once Spinnaker and OES are installed successfully, we need to configure Spinnaker in Autopilot UI.&#x20;

   Navigate to Setup → Spinnaker → Add Spinnaker.&#x20;

   The following fields need to be provided:&#x20;

   * *Spinnaker Name: User defined name of Spinnaker Instance*&#x20;
   * *Spinnaker Gate URL: The Gate URL of the Spinnaker instance*&#x20;
   * *Authentication Type: Mechanism with which Autopilot communicates to Spinnaker.*
   * *Mention, **LDAP**, for Basic Authentication (username with password) or **X509**, for 2 Factor Authentication systems.*

   **Using the LDAP Mechanism**

   Provide the username and password of the user who has the access to all the pipelines in the encrypted base64 format using this command,&#x20;

   `echo -ne “username:password” | base64 -w0`

   **Using the x509 Mechanism**

   * To Enable x509 method of Authentication for Spinnaker, please refer to the steps in <https://spinnaker.io/setup/security/authentication/x509/>
   * For Autopilot to communicate with Spinnaker using x509, we need a client p12 key.&#x20;
   * Using the client.p12 key and password, we can configure Autopilot to communicate with Spinnaker on the x509 port.&#x20;
   * Assuming that we have client tls certificate and key, we can generate a p12 using the following command,&#x20;

   `$ openssl pkcs12 -export -clcerts -in x509lb.crt -inkey x509lb.key -out x509lb.p12 -name gate509lb -password pass:changeit`
