Using OpenShift¶
You can use containerized execution using OpenShift 4 as the underlying Kubernetes engine.
Setup¶
Prepare the DSS host¶
The following commands must be installed on the DSS host and usable by the user running DSS:
oc, the OpenShift CLI. See the OpenShift documentation on the oc CLI. DSS usesocto run image builds and tag images.skopeo, used by the OpenShift builder to push the DSS base images to the OpenShift registry through its external URL.
Create a service account for DSS¶
DSS authenticates to OpenShift with a dedicated service account rather than with a personal user account. The service account token is stored in a kubeconfig file on the DSS host, and DSS uses it both to run workloads and to authenticate to the OpenShift image registry. Create the namespace and the service account:
oc new-project dataiku-exec
oc create serviceaccount dataiku-sa -n dataiku-exec
Grant the service account the edit role in this namespace. DSS uses the same namespace to build images and to run workloads.
This role covers what DSS needs: build configurations, builds, image streams, pods, services, and secrets, as well as pushing images to the internal registry.
oc policy add-role-to-user edit -z dataiku-sa -n dataiku-exec
Note
The edit role is namespace-scoped. Keep Auto-create namespace disabled in the image build and containerized execution configurations: the namespace already exists, and creating namespaces would require cluster-level permissions.
Create a long-lived token for the service account. On OpenShift 4.11 and later, service accounts no longer get a long-lived token secret automatically, and tokens obtained with oc create token expire. Since DSS uses a static kubeconfig, create a token secret bound to the service account:
oc apply -n dataiku-exec -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: dataiku-sa-token
annotations:
kubernetes.io/service-account.name: dataiku-sa
type: kubernetes.io/service-account-token
EOF
For more information, see the OpenShift documentation on service accounts.
Create the kubeconfig file¶
On the DSS host, as the user running DSS, build a dedicated kubeconfig file from the service account token and the cluster CA certificate:
KUBECONFIG_FILE=/data/dataiku/.kube/openshift-dataiku.conf
API_SERVER=https://api.cluster.example.com:6443
TOKEN=$(oc get secret dataiku-sa-token -n dataiku-exec -o jsonpath='{.data.token}' | base64 -d)
oc get secret dataiku-sa-token -n dataiku-exec -o jsonpath='{.data.ca\.crt}' | base64 -d > /tmp/openshift-ca.crt
oc config set-cluster openshift --server="$API_SERVER" --certificate-authority=/tmp/openshift-ca.crt --embed-certs=true --kubeconfig="$KUBECONFIG_FILE"
oc config set-credentials dataiku-sa --token="$TOKEN" --kubeconfig="$KUBECONFIG_FILE"
oc config set-context dataiku-openshift --cluster=openshift --user=dataiku-sa --namespace=dataiku-exec --kubeconfig="$KUBECONFIG_FILE"
oc config use-context dataiku-openshift --kubeconfig="$KUBECONFIG_FILE"
chmod 600 "$KUBECONFIG_FILE"
rm /tmp/openshift-ca.crt
The kubeconfig must authenticate with a token, not with a client certificate: the OpenShift builder retrieves the token with oc whoami --show-token to authenticate to the image registry.
Check that the kubeconfig works and that the service account has the expected permissions:
oc --kubeconfig="$KUBECONFIG_FILE" whoami
# system:serviceaccount:dataiku-exec:dataiku-sa
oc --kubeconfig="$KUBECONFIG_FILE" auth can-i create buildconfigs -n dataiku-exec
oc --kubeconfig="$KUBECONFIG_FILE" auth can-i create pods -n dataiku-exec
Declare the OpenShift cluster in DSS¶
Dataiku leverages Kubernetes as the base cluster API for workload runtime. Dataiku does not manage OpenShift clusters. Only “unmanaged” operation is possible. Declare the OpenShift cluster in DSS as a dedicated non-managed Kubernetes cluster that points to this kubeconfig file:
In Administration > Clusters, create a cluster of type Non managed with the K8S architecture.
In the cluster Containerized execution tab, enable Override global settings and Override execution configs.
Set Kube config path to the kubeconfig file created above, Kubectl Context to
dataiku-openshift, and Kubernetes Namespace todataiku-exec.
You can configure the memory allocation for each container using multiple containerized execution configurations.
Create new image build and containerized execution configurations¶
The image build and containerized execution configurations are defined in the global DSS Containerized execution settings. To use the cluster, select it as the default cluster for containerized execution, either globally in Administration > Settings > Containerized execution or per project. See Managed Kubernetes clusters for how DSS selects the cluster to use.
Go to Administration > Settings > Containerized Execution.
Add a new image build configuration.
Select OpenShift as the builder type.
Set Cluster to the cluster declared above. DSS runs
ocwith this cluster’s kubeconfig and context.Set the OpenShift namespace to
dataiku-exec. By default, images are published into the registry in the same namespace where the build action is performed.Add a new container execution configuration of type Kubernetes.
Warning
Changing the OpenShift namespace will most likely require rebuilding all container images built by Dataiku. Depending on your setup, images are only published in this namespace.
You can optionally configure additional namespaces you want images to be made available using Target Namespaces. Once the build is finished, the images will be copied into the target namespaces.