solidnerd / terraform-k8s-hcloud

A simple project to spin your k8s cluster with terraform, kubeadm on hcloud
MIT License
89 stars 37 forks source link

Always newest docker version installed #2

Closed ppeczek closed 6 years ago

ppeczek commented 6 years ago

Despite

variable "docker_version" {
  default = "17.03"
}

installed version of docker is 18.03.1-ce. That produces error:

[WARNING SystemVerification]: docker version is greater than the most recently validated version. Docker version: 18.03.1-ce. Max validated version: 17.03

edit: indeed always the newest version is installed:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
ppeczek commented 6 years ago

Seems the problem was that for ubuntu 18.04 docker 17.03 isn't supported. But still, need to check if the problem of setting docker version still exists

solidnerd commented 6 years ago

Hey @ppeczek ,

I will try to explain how the version will be determined. Important is that package pinning will be used to ensure the version of installed package.

  1. Write a file under /etc/apt/preferences.d/docker-ce to pin the docker-ce package to the determined version. In this case I will be written to this

    Package: docker-ce
    Pin: version 17.03.*
    Pin-Priority: 1000

    This means that the latest patch will be also included. APT does the job for us to find the latest available package in the repository. https://github.com/solidnerd/terraform-k8s-hcloud/blob/master/scripts/bootstrap.sh#L8 Debian APT Pinning

  2. Afterwards we pinned the package it will add the docker-ce ubuntu repository with the correct correct code name. For that we use lsb_release -cs to determine the codename.

  3. Then the normal procedure goes on.

Your described problem comes directly from docker because the don't support 17.03 on 18.04 and I think the won't in future. They will only release the recent version of docker in 18.04 . So I think this will be docker-ce 18.06

If you want to use ubuntu 18.04 and docker 17.03 you could do this by a workaround to install the 17.03 from the xenial repo but it's not supported by anyone.

For this you can replace:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

with

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   xenial \
   stable"

I will close this now, because it's not a problem of this project.