Configuring a repository warehouse for a SAS® Viya® platform deployment at a dark site


A dark site deployment is commonly described as a deployment on infrastructure that has no outbound internet connectivity. The term dark site is often used interchangeably with the concept of building a private Kubernetes cluster and associated infrastructure that contains no public IPs, Subnets and so on. In this SAS KB article, the term dark site refers to a SAS® Viya® deployment to a cluster with no outbound internet access.

On the SAS Viya platform, this dark site scenario can pose the following challenges:

  1. SAS Viya platform container images are pulled from an external source (cr.sas.com). Running the SAS Viya platform in a Kubernetes cluster without the necessary external access to gather these resources requires additional configuration changes for the deployment to complete successfully. Luckily, SAS® Mirror Manager provides a solution for creating an internally accessible copy of the required container images.
  2. The provisioning of the platform container images requires some additional metadata information (from ses.sas.download) in the form of a repository warehouse.

This SAS KB article explores what is required to set up an internal repository warehouse and explains how you can configure the SAS Viya platform deployment process to consume that metadata. It uses accessible shared storage and the file:// protocol to reference it.

Table of Contents


Dark Site Deployment Considerations

You can use SAS Mirror Manager to create a local copy of the container images required for deployment. In addition to container images, SAS Mirror Manager also generates repository metadata describing:

This metadata is referred to as the repository warehouse.

At deployment time, the SAS Deployment Operator must be able to access this repository warehouse. In cases where outbound connectivity is not possible, you can make the repository warehouse available through any storage technology that you can mount into Kubernetes workloads, such as the following

Note: The remainder of this article focuses on the file-system based approach.


Populating the Repository Warehouse Using SAS Mirror Manager

After running SAS Mirror Manager, repository metadata is generated alongside the mirrored deployment content.

If you execute SAS Mirror Manager with the --path (-p) option, the repository metadata is stored in the specified directory.

For deployments that use the default location, the repository metadata is located under $HOME/sas_repos.

Copy the following content to storage that will be accessible from the Kubernetes environment:

entitlements.json
cadences/shipped.mc
rel/<cadence>/<version>
lod/<cadence>/<version>/<release>

Once copied, you can expose the repository warehouse using any supported shared storage mechanism.

The following examples use NFS export, but the same concepts apply to other storage technologies.


Making the Repository Warehouse Available to the SAS Viya Platform Deployment Operator

The Deployment Operator itself needs access to the repository metadata. Mount the repository warehouse into the Deployment Operator pod using a simple PatchTransformer:

apiVersion: builtin
kind: PatchTransformer
metadata:
  name: deployment-operator-warehouse-volume
patch: |-
  - op: add
    path: /spec/template/spec/volumes/-
    value:
      name: deployment-operator-repository-warehouse
      nfs:
        path: {{ Exported-repository-path }}
        server: {{ NFS-server-address }}

  - op: add
    path: /spec/template/spec/containers/0/volumeMounts/-
    value:
      name: deployment-operator-repository-warehouse
      mountPath: /repository

target:
  kind: Deployment
  name: sas-deployment-operator

Once you deploy the Deployment Operator, repository warehouse information becomes available within the operator Pod at /repository.

Store a copy of this transformer as $operator-deploy/site-config/add-repository-warehouse.yaml. 

Important: This configuration affects only the SAS Viya platform Deployment Operator pod. It does not automatically make the repository warehouse available to resources generated by the operator.


Making the Repository Warehouse Available to Operator-Created Workloads

Why an Additional Step is Required

A common assumption is that mounting storage into the Deployment Operator automatically makes it available to workloads created by the operator. However, this is not the case. 

When the SAS Deployment Operator processes a SASDeployment resource, it dynamically generates Kubernetes resources, such as a reconciliation Job and an auto-update Cronjob. These resources are generated dynamically and are applied in the cluster via stdin. The changes made so far apply to only the operator Pod, not to the workloads that it creates.

Intercepting the Generated Manifest

The Deployment Operator includes the yq utility and supports reconcile transformers. A reconcile transformer can intercept the generated manifest before it is applied and inject additional Kubernetes configuration.

You can use this mechanism to add the same repository warehouse mount to resources generated by the operator.

Step 1: Create the Reconcile Transformer Script

The following example adds a repository warehouse volume and mount to generated Job and CronJob resources:

#!/bin/sh
yq eval 'select(.kind=="Job").spec.template.spec.volumes += {"name":"repository-warehouse","nfs":{"path":"{{ Exported-repository-path }}","server":"{{ NFS-server-address }}"}}' - |
yq eval 'select(.kind=="Job").spec.template.spec.containers[0].volumeMounts += {"mountPath":"/repository","name":"repository-warehouse"}' - |
yq eval 'select(.kind=="CronJob").spec.jobTemplate.spec.template.spec.volumes += {"name":"repository-warehouse","nfs":{"path":"{{ Exported-repository-path }}","server":"{{ NFS-server-address }}"}}' - |
yq eval 'select(.kind=="CronJob").spec.jobTemplate.spec.template.spec.containers[0].volumeMounts += {"mountPath":"/repository","name":"repository-warehouse"}' -

Store a copy of this script as $operator-deploy/site-config/add-repository-warehouse.sh.

Step 2: Create a ConfigMap

Create a ConfigMap that contains the transformer script:

apiVersion: builtin
kind: ConfigMapGenerator
metadata:
  name: repository-warehouse-reconcile-transformer

files:
  - repository-warehouse=site-config/add-repository-warehouse.sh 

Store the ConfigMapGenerator as $operator-deploy/site-config/add-repository-warehouse-configmap.yaml.

Step 3: Mount the Transformer into the Deployment Operator

Mount the ConfigMap into the Deployment Operator and configure it as a reconcile transformer:

apiVersion: builtin
kind: PatchTransformer
metadata:
  name: sas-deployment-operator-reconcile-warehouse

patch: |-
  - op: add
    path: /spec/template/spec/volumes/-
    value:
      name: repository-warehouse-reconcile-transformer
      configMap:
        defaultMode: 493
        name: repository-warehouse-reconcile-transformer
        items:
        - key: repository-warehouse
          path: repository-warehouse

  - op: add
    path: /spec/template/spec/containers/0/volumeMounts/-
    value:
      mountPath: /reconcile-transformers/user/repository-warehouse
      name: repository-warehouse-reconcile-transformer
      subPath: repository-warehouse

  - op: add
    path: /spec/template/spec/containers/0/env/-
    value:
      name: RECONCILE_TRANSFORMER
      value: user/repository-warehouse

target:
  kind: Deployment
  name: sas-deployment-operator

The RECONCILE_TRANSFORMER environment variable identifies the transformer script that should be executed during reconciliation.

Store the PatchTransformer as $operator-deploy/site-config/add-repository-warehouse-transformer.yaml.

Update $operator-deploy/kustomization.yaml

The additional transformer resources must be referenced in the deployment operator kustomization.yaml.

Here is an example:

resources:
  - operator-base
generators:
  - site-config/add-repository-warehouse-configmap.yaml
transformers:
  - site-config/transformer.yaml
  - site-config/cluster-wide-transformer.yaml
  - site-config/add-repository-warehouse.yaml
  - site-config/add-repository-warehouse-transformer.yaml
  - site-config/mirror.yaml

With these amendments in place, you can deploy the SAS Viya platform Deployment Operator as documented. Once applied, the compiled repository warehouse information will be available to both the SAS Viya platform Deployment Operator, as well as the resources that it spawns.


Create a SASDeployment Custom Resource Using the --repository-warehouse Argument with the file:// Protocol

After you mount and expose the repository warehouse to all required operator-managed workloads, deployments can reference the repository warehouse directly from the local file system.

Because the examples above mount the repository warehouse at /repository, you can generate the deployment custom resource using the following:

--repository-warehouse file:///repository

See Command Format for additional information.


Summary

This SAS KB article demonstrates how to configure a file system-based repository warehouse for use in dark site deployments. By populating the repository warehouse with content generated by SAS Mirror Manager, mounting that content into the SAS Deployment Operator, and using a reconcile transformer to extend the operator-generated workloads, repository metadata can be consumed directly from shared storage. The resulting deployment can use the --repository-warehouse file:///repository option, which provides an alternative to hosting repository metadata through an internal web server or from accessing it directly from SAS hosted repositories.