Installing an agent relay in an OpenShift/Kubernetes cluster#
UrbanCode Deploy Agent Relay is a tool for automating application deployments through your environments. It is designed to facilitate rapid feedback and continuous delivery in agile development while providing the audit trails, versioning and approvals needed inproduction.
Introduction
This chart deploys a single instance of the HCL UrbanCode Deploy agent relay that may be scaled to multiple instances.
Chart Details
- Includes a StatefulSet workload object and corresponding service.
Prerequisites
- Kubernetes 1.9+; kubectl and oc CLI; Helm/Tiller 2.9.1;
- Install and setup oc/kubectl CLI
- Install and setup the Helm CLI Be sure to set HELM_VERSION=v2.9.1.
-
Image and Helm Chart - The UrbanCode Deploy agent relay image and helm chart can be accessed either via the Entitled Registry and public Helm repository, or by downloading a Passport Advantage archive (PPA) and loading the image and helm chart into your own image registry and helm repository.
- Entitled Registry
- The public Helm chart repository can be accessed at https://github.com/HCL/charts/tree/master/entitled and directions for accessing the UrbanCode Deploy server chart is discussed in Installing the Chart section below.
- Get a key to the entitled registry
- Log in to MyHCL Container Software Library with the HCLid and password that are associated with the entitled software.
- In the Entitlement keys section, select Copy key to copy the entitlement key to the clipboard.
- An imagePullSecret must be created to be able to authenticate and pull images from the Entitled Registry. Once this secret has been created you will specify the secret name as the value for the image.secret parameter in the values.yaml you provide to 'helm install ...' Note: Secrets are namespace scoped, so they must be created in every namespace you plan to install UCD into. Example Docker registry secret to access Entitled Registry with an Entitlement key.
```
oc create secret docker-registry entitledregistry-secret --docker-username=cp --docker-password=
--docker-server=cp.icr.io
```
- Passport Advantage archive
- Download the PPA archive for your operating system from the HCL Passport Advantage website.
- Load the image and helm chart into your cluster using cloudctl catalog load-archive.
- The UrbanCode agent relay must have a UrbanCode Deploy server to connect to.
- A PersistentVolume (PV) that will hold the conf directory for the UrbanCode Deploy agent relay is required. This same PV is used to persist the agent relay cache data if caching is enabled and persisted. If your cluster supports dynamic volume provisioning you will not need to create a PV or PersistentVolumeClaim (PVC) before installing this chart. If your cluster does not support dynamic volume provisioning, you will need to either ensure a PV is available or you will need to create one before installing this chart. You can optionally create the PVC to bind it to a specific PV, or you can let the chart create a PVC and bind to any available PV that meets the required size and storage class. Sample YAML to create the PV and PVC are provided below.
apiVersion: v1 kind: PersistentVolume metadata: name: ucdr-conf-vol labels: volume: ucdr-conf-vol spec: capacity: storage: 10Mi accessModes: ReadWriteOnce nfs: server: 192.168.1.17 path: /volume1/k8/ucdr-conf kind: PersistentVolumeClaim apiVersion: v1 metadata: name: ucdr-conf-volc spec: storageClassName: "" accessModes: "ReadWriteOnce" resources: requests: storage: 10Mi selector: matchLabels: volume: ucdr-conf-vol
Example setup scripts to create the Persistent Volume and Persistent Volume Claim are included in the Helm chart under pak_extensions/pre-install/persistentStorageAdministration directory.
- Entitled Registry
-
Secret - A Kubernetes Secret object must be created to store the CodeStation authentication token. The authentication token is retrieved during Helm chart installation. By default, the chart will look for a secret named 'HelmReleaseName-secrets' where 'HelmReleaseName' is the release name you give when installing this Helm chart. You can also create a secret with a different name and specify it in the Values.secret.name field.
-
Through the oc CLI, create a Secret object in the target namespace. Generate the base64 encoded value for the CodeStationauthentication token
echo -n 255b21b7-ca48-4f2e-95c0-048fdbff4197 | base64 MjU1YjIxYjctY2E0OC00ZjJlLTk1YzAtMDQ4ZmRiZmY0MTk3
-
Create a file named secret.yaml with the following contents, using your Helm Relese name and base64 encoded values.
apiVersion: v1 kind: Secret metadata: name: MyRelease-secrets type: Opaque data: cspassword: MjU1YjIxYjctY2E0OC00ZjJlLTk1YzAtMDQ4ZmRiZmY0MTk3 relay-README.md - Grip http://localhost:6419/ 2
-
Create the Secret using oc apply: oc apply -f ./secret.yaml
- Delete or shed the secret.yaml file.
-
PodSecurityPolicy Requirements
If you are running on OpenShift, skip this section and continue to the SecurityContextConstraints Requirements section below.
This chart requires a PodSecurityPolicy to be bound to the target namespace prior to installation. Choose either a predefined PodSecurityPolicy or have your cluster administrator create a custom PodSecurityPolicy for you.
The predefined PodSecurityPolicy named ibm-restricted-psp
has been verified for this chart, if your target namespace is bound to this PodSecurityPolicy you can proceed to install the chart.
This chart also defines a custom PodSecurityPolicy which can be used to finely control the permissions/capabilities needed to deploy this chart. You can enable this custom PodSecurityPolicy using the Cluster Console user interface or the supplied instructions/scripts in the pak_extension pre-install directory.
-
From the user interface, you can copy and paste the following snippets to enable the custom PodSecurityPolicy
-
Custom PodSecurityPolicy definition:
```
apiVersion: extensions/v1beta1 kind: PodSecurityPolicy metadata: annotations: kubernetes.io/description: "This policy is based on the most restrictive policy, requiring pods to run with a non-root UID, and preventing pods from accessing the host." seccomp.security.alpha.kubernetes.io/allowedProfileNames: docker/default seccomp.security.alpha.kubernetes.io/defaultProfileName: docker/default name: ibm-ucd-prod-psp spec: allowPrivilegeEscalation: false forbiddenSysctls: - '*' fsGroup: ranges: - max: 65535 min: 1 rule: MustRunAs hostNetwork: false hostPID: false hostIPC: false requiredDropCapabilities: - ALL runAsUser: rule: MustRunAsNonRoot seLinux: rule: RunAsAny supplementalGroups: ranges: - max: 65535 min: 1 rule: MustRunAs volumes: - configMap - emptyDir - projected - secret - downwardAPI - persistentVolumeClaim
```
-
Custom ClusterRole for the custom PodSecurityPolicy:
```
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: ibm-ucd-prod-clusterrole rules: - apiGroups: - extensions resourceNames: - ibm-ucd-prod-psp resources: - podsecuritypolicies verbs: - use
```
-
RoleBinding for all service accounts in the current namespace. Replace
```
{{NAMESPACE }} ```
in the template with the actual namespace.
```
apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: ibm-ucd-prod-rolebinding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: ibm-ucd-prod-clusterrole subjects: - apiGroup: rbac.authorization.k8s.io kind: Group name: system:serviceaccounts:{{ NAMESPACE }}
```
-
-
From the command line, you can run the setup scripts included under pak_extensions.
As a cluster administrator, the pre-install scripts and instructions are located at:
-
pre-install/clusterAdministration/createSecurityClusterPrereqs.sh As team admin/operator the namespace scoped scripts and instructions are located at:
-
pre-install/namespaceAdministration/createSecurityNamespacePrereqs.sh
-
SecurityContextConstraints Requirements
If running in a Red Hat OpenShift cluster, this chart requires a SecurityContextConstraints
to be bound to the target namespace prior to installation. To meet this requirement there may be cluster scoped as well as namespace scoped pre and post actions that need to occur.
The predefined SecurityContextConstraints
name: ibm-restricted-scc
has been verified for this chart, if your target namespace is bound to this SecurityContextConstraints
resource you can proceed to install the chart.
This chart defines a custom SecurityContextConstraints
which can be used to finely control the permissions/capabilities needed to deploy this chart. You can enable this custom SecurityContextConstraints
resource using the supplied instructions or scripts in the pak_extensions/pre-install
directory.
-
From the user interface, you can copy and paste the following snippets to enable the custom
SecurityContextConstraints
- Custom SecurityContextConstraints definition: ```
apiVersion: security.openshift.io/v1 kind: SecurityContextConstraints metadata: annotations: name: ibm-ucd-prod-scc allowHostDirVolumePlugin: false allowHostIPC: false allowHostNetwork: false allowHostPID: false allowHostPorts: false allowPrivilegedContainer: false allowedCapabilities: [] allowedFlexVolumes: [] defaultAddCapabilities: [] defaultPrivilegeEscalation: false forbiddenSysctls: - "*" fsGroup: type: MustRunAs ranges: - max: 65535 min: 1 readOnlyRootFilesystem: false requiredDropCapabilities: - ALL runAsUser: type: MustRunAsNonRoot seccompProfiles: - docker/default seLinuxContext: type: RunAsAny supplementalGroups: type: MustRunAs ranges: - max: 65535 min: 1 volumes: - configMap - downwardAPI - emptyDir - persistentVolumeClaim - projected - secret priority: 0 ```
-
From the command line, you can run the setup scripts included under
pak_extensions/pre-install
As a cluster admin the pre-install instructions are located at:-
pre-install/clusterAdministration/createSecurityClusterPrereqs.sh
As team admin the namespace scoped instructions are located at: -
pre-install/namespaceAdministration/createSecurityNamespacePrereqs.sh
-
Resources Required
- 2GB of RAM
- 2 CPU core
Installing the Chart
Add the Entitled Registry helm chart repository to the local client.
- $ helm repo add entitled https://raw.githubusercontent.com/HCL/charts/master/repo/entitled/
Get a copy of the values.yaml file from the helm chart so you can update it with values used by the install.
- $ helm inspect values entitled/ibm-ucdr-prod > myvalues.yaml
Edit the file myvalues.yaml to specify the parameter values to use when installing the UrbanCode Deploy agent relay instance. The configuration section lists the parameter values that can be set.
To install the chart into namespace 'ucdtest' with the release name my-ucdr-release and use the values from myvalues.yaml:
- $ helm install --namespace ucdtest --name my-ucdr-release --values myvalues.yaml entitled/ibm-ucdr-prod
Tip: List all releases using helm list .
Verifying the Chart
Check the Resources->Agents Relays page of the UrbanCode Deploy server UI to verify the agent has connected successfully.
Uninstalling the Chart
To uninstall/delete the my-ucdr-release deployment:
$ helm delete my-ucdr-release
The command removes all the Kubernetes components associated with the chart and deletes the release.
Configuration
Helm chart configuration parameters for agent relay
Storage
See the Prerequisites section of this page for storage information.
Parent topic: Installing agent relays