sassoftware / sas-container-recipes

A collection of recipes and other resources for building containers that include SAS Viya software.
https://www.sas.com
Apache License 2.0
89 stars 42 forks source link

viya-single-container running on K8S cluster cannot apply a new SAS license without rebuild #60

Open splmie opened 2 years ago

splmie commented 2 years ago

I've built SAS Viya 3.5 single container using your framework build.sh and SAS_Viya_deployment_data.zip including SAS license A. Containers created from the image run inside kubernetes cluster. After I added SETINIT_TEXT variable into kubernetes Config Map contained SAS license B and changed the manifest starting Viya containers I expected new Viya containers will start with SAS license B. Unfortunetly this functionality is not working for the image as described in doc https://go.documentation.sas.com/doc/en/dplyml0phy0dkr/3.5/n0qu54bw8k60fqn1rpevg0qnx0q0.htm New Viya containers still have applied SAS license A in CAS and Foundation. The only change is inside Viya container we have SETINIT_TEXT env variable with license B.

After few tests I found I can change the SAS license only for pre-build single Viya container image downloaded from ses.sas.download docker repository. In example: ses.sas.download/va-125-x64_redhat_linux_7-docker/sas-viya-programming:3.5.11-20210528.1622225215043

splmie commented 2 years ago

I found the solution by myself.

1) Create kubernetes config map with spre.SETINIT_TEXT variable 2) Put the content of your new SAS license into spre.SETINIT_TEXT.

  spre.SETINIT_TEXT: |
    PROC SETINIT RELEASE='V03';
    SITEINFO NAME='XXXXXXXX'
    SITE=123456789 OSNAME='LIN X64' RECREATE WARN=34 GRACE=62
    [..]
    SAVE; RUN;

3) Inside the SPRE container set environment variable SETINIT_TEXT and initialize it with value of spre.SETINIT_TEXT from kubernetes config map.

TIP: you have to modify the manifest starting your SPRE container by putting this section

    spec:
      containers:
      - env:
        - name: SETINIT_TEXT
          valueFrom:
            configMapKeyRef:
              key: spre.SETINIT_TEXT
              name: spre-config

4) entrypoint for the SPRE image need to be modified by putting that code before CAS starts

     echo;echo "===== [INFO] : Checking SAS license =====";

        if [ ! -z "${SETINIT_TEXT}" ]; then
            export SASLICENSEFILE="license.sas"
            export SASLICENSEDIR="/sasinside"
            echo;echo "===== [INFO] : Found new SAS license! =====";echo;
            echo;echo "${SETINIT_TEXT}";echo;
            echo;echo "===== [INFO] : Applying new SAS license =====";echo;
            echo "${SETINIT_TEXT}" > ${SASLICENSEDIR}/${SASLICENSEFILE}
            # Applying license to SAS Foundation
            sudo su -s "/bin/sh" -c "/opt/sas/spre/home/SASFoundation/utilities/bin/apply_license ${SASLICENSEDIR}/${SASLICENSEFILE}" sas
            # Applying license to CAS
            sudo su -s "/bin/sh" -c "ln -sf ${SASLICENSEDIR}/${SASLICENSEFILE} /opt/sas/viya/config/etc/cas/default/sas_license.txt" sas
        else
            echo;echo "===== [INFO] : No changes, skipping  =====";echo;
        fi