sassoftware / viya4-deployment

This project contains Ansible code that creates a baseline in an existing Kubernetes environment for use with the SAS Viya Platform, generates the manifest for an order, and then can also deploy that order into the Kubernetes environment specified.
Apache License 2.0
71 stars 64 forks source link

docker build -> build-arg not getting picked up for kubectl_version #190

Closed ClemensRieseSAS closed 2 years ago

ClemensRieseSAS commented 2 years ago

Regarding: https://github.com/sassoftware/viya4-deployment/blob/main/docs/user/Dependencies.md

The resulting Command would be:

docker build \
    --build-arg kustomize_version=3.7.0 \
    --build-arg kubectl_version=1.19.9 \
    --build-arg aws_iam_authenticator_version=1.18.9/2020-11-02 \
    --build-arg pip_ansible_version=2.10.7 \
    --build-arg pip_openshift_version=0.12.0 \
    --build-arg pip_kubernetes_version=12.0.1 \
    --build-arg pip_dnspython=2.1.0 \
    --build-arg ansible_galaxy_community_kubernetes_version=1.2.1 \
-t viya4-deployment .

During the build kubectl will be installed in v1.21.8. This is because of after every FROM statements all the ARGs get collected and are no longer available (see: https://stackoverflow.com/questions/44438637/arg-substitution-in-run-command-not-working-for-dockerfile)

thpang commented 2 years ago

I tested this and found no issue. Here are the steps I followed:

  1. First build the docker image:
    docker build --file ./Dockerfile --build-arg TIMESTAMP=$(date +%s) --build-arg kubectl_version=1.21.6 --tag viya-deployment .
  2. Once the image was created I ran the container:
    docker run --rm -it --group-add root --user $(id -u):$(id -g) --volume $HOME/.aws:/.aws --volume $HOME/.azure:/.azure --volume $HOME/.google:/.google --entrypoint bash viya-deployment
  3. While inside the container I typed the following command:
    kubectl version

    The output is as follows:

    Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.6", GitCommit:"d921bc6d1810da51177fbd0ed61dc811c5228097", GitTreeState:"clean", BuildDate:"2021-10-27T17:50:34Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}

    Here you can see the kubectl version was set to 1.21.6 as I stated when building the image.

If you can provide more information on your issue, we'll gladly evaluate; however, given my findings if there are is no other information you can provide we'll be closing this one. Thx.

ClemensRieseSAS commented 2 years ago

Hello,

if found this mismatch in the docker build command:

Command:

docker build \
    --build-arg kustomize_version=3.7.0 \
    --build-arg kubectl_version=1.19.9 \
    --build-arg aws_iam_authenticator_version=1.18.9/2020-11-02 \
    --build-arg pip_ansible_version=2.10.7 \
    --build-arg pip_openshift_version=0.12.0 \
    --build-arg pip_kubernetes_version=12.0.1 \
    --build-arg pip_dnspython=2.1.0 \
    --build-arg ansible_galaxy_community_kubernetes_version=1.2.1 \
-t viya4-deployment .

Output (partial):

Step 5/23 : ARG kubectl_version=1.21.8
 ---> Running in 8a51213a2722

So is this mismatch in the docker build command just misleading? Did you try to use the "correct" kubectl (v1.19.9) specified in https://github.com/sassoftware/viya4-deployment/blob/main/docs/user/Dependencies.md?

thpang commented 2 years ago

@ClemensRieseSAS, have you actually run the docker image to see what kubectl version is included in the image? That's a task you have to verify.

ClemensRieseSAS commented 2 years ago

Hello,

you are correct: In the container/image itself the kubectl version is correct:

docker run --rm -it --group-add root --user $(id -u):$(id -g) --entrypoint bash viya4-deployment

root@d179279f08dd:~# kubectl version --client
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.9", GitCommit:"9dd794e454ac32d97cde41ae10be801ae98f75df", GitTreeState:"clean", BuildDate:"2021-03-18T01:09:28Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}

Nether the less is the message during the docker build misleading.