Puppet Kubernetes Error while applying a puppet manifest to add the kubernetes repository

0 votes

I'm trying to configure an Ubuntu 18.04 using Puppet as a Kubernetes master. There's a puppet manifest on puppet master which defines the required configurations to install the kublet, kubeadm, and kubectl packages on the Ubuntu server, where i am trying to add the kubernetes repo using apt module of puppet.

sudo puppet agent -t

Here's the output.

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for buildserver.mycompany.com
Info: Applying configuration version '1549042128'
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install kubelet' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package kubelet
Error: /Stage[main]/Kubernetes/Package[kubelet]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install kubelet' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package kubelet
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install kubeadm' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package kubeadm
Error: /Stage[main]/Kubernetes/Package[kubeadm]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install kubeadm' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package kubeadm
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install kubectl' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package kubectl
Error: /Stage[main]/Kubernetes/Package[kubectl]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install kubectl' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package kubectl
Notice: /Stage[main]/Kubernetes/Apt::Source[kubernetes]/Apt::Setting[list-kubernetes]/File[/etc/apt/sources.list.d/kubernetes.list]/ensure: defined content as '{md5}a0ab4048dbab52eed3aa72b3b6b533cf'
Info: /Stage[main]/Kubernetes/Apt::Source[kubernetes]/Apt::Setting[list-kubernetes]/File[/etc/apt/sources.list.d/kubernetes.list]: Scheduling refresh of Class[Apt::Update]
Info: Class[Apt::Update]: Scheduling refresh of Exec[apt_update]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Ign:2 https://packages.cloud.google.com/apt bionic InRelease
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Err:4 https://packages.cloud.google.com/apt bionic Release
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns:   404  Not Found [IP: 172.217.6.14 443]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Get:6 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Reading package lists...
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: E: The repository 'http://apt.kubernetes.io bionic Release' does not have a Release file.
Error: /Stage[main]/Apt::Update/Exec[apt_update]: Failed to call refresh: '/usr/bin/apt-get update' returned 100 instead of one of [0]
Error: /Stage[main]/Apt::Update/Exec[apt_update]: '/usr/bin/apt-get update' returned 100 instead of one of [0]
Info: Class[Kubernetes]: Unscheduling all events on Class[Kubernetes]
Notice: Applied catalog in 4.19 seconds

Here's the manifest's code snippet:

include apt
class kubernetes {
    file { '/opt/apt-key.gpg':
        source => [
            "https://packages.cloud.google.com/apt/doc/apt-key.gpg"
        ]
    }
    apt::key { 'kubernetes-repository':
        id => '54A647F9048D5688D7DA2ABE6A030B21BA07F4FB',
        source => 'https://packages.cloud.google.com/apt/doc/apt-key.gpg',
    }
    apt::source { 'kubernetes':
        comment => 'This is the kubernetes repository',
        location => 'http://apt.kubernetes.io/',
        repos => 'kubernetes-xenial main',
        key => {
            'id' => '54A647F9048D5688D7DA2ABE6A030B21BA07F4FB',
        },
        include => {
            'deb' => true,
        },
    }
    package { 'kubelet':
        ensure => installed,
    }
    package { 'kubeadm':
        ensure => installed,
    }
    package { 'kubectl':
        ensure => installed,
    }
}
node 'buildserver.mycompany.com' {
    include kubernetes
}

The apt module, apt::source is creating the /etc/apt/sources.list.d/kubernetes.list file, but the entry for the repository in this file has an unwanted repository added to it. How can I prevent this error?

Aug 22, 2019 in Puppet by Karan
• 19,610 points
1,286 views

1 answer to this question.

0 votes

I guess there isn't an issue with the module. 

Try to pass an empty string value for the 'release' value in apt::source. This might prevent it.

The template that generates the /etc/apt/sources.list.d/kubernetes.list file (source.list.epp) prefixes the provided 'release' value prior to the provided list of repositories. 

On Ubuntu 18.04, when no 'release' value is provided it appears to resolve to 'bionic', which is how it was ending up in the file. 

Your manifest should look like this:

apt::source { 'kubernetes':
    comment => 'This is the kubernetes repository',
    location => 'http://apt.kubernetes.io/',
    release => '',
    repos => 'kubernetes-xenial main',
    key => {
        'id' => '54A647F9048D5688D7DA2ABE6A030B21BA07F4FB',
    },
    include => {
        'deb' => true,
    },
}

 [<%- if ($opt_architecture) {%>arch=<%= $opt_architecture %><% } %><%if ($opt_architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %>

Ready to master Kubernetes and take your container orchestration skills to the next level? Join our comprehensive Kubernetes Course today.

answered Aug 22, 2019 by Sirajul
• 59,230 points

Related Questions In Puppet

0 votes
1 answer

Error while enabling the official puppet lab collection repository

Hey @Alia, try executing these commands and ...READ MORE

answered Feb 25, 2019 in Puppet by Nandita
964 views
0 votes
1 answer
0 votes
1 answer

Error while trying to instal mssql tools using puppet

When you use puppet, you don't use ...READ MORE

answered Feb 25, 2019 in Puppet by Nandita
1,779 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,477 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
0 votes
0 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP