Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl monks, I'm a newbie DevOps engineer in the East coast. I'm trying to use Net::Kubernetes to interact with K8S cluster thru Perl, but running into some issue while instantiating the kube object with the new() method. CPAN's documentation mentions those SSL key certificate options but doesn't provide concrete example. And I couldn't find usage examples of Net::Kubernetes on the web either.... So, anyway, here's my code:
my $kube = Net::Kubernetes->new( url => 'https://myK8Scluster:8443', username => 'kubernetes-admin', ssl_ca_file => '/src/ssl_ca_file.txt', ssl_cert_file => '/src/ssl_cert_file.txt', ssl_key_file => '/src/ssl_key_file.txt' );
where the values for url and those ssl params. come from the Kubernetes server's "$HOME/.kube/config" file. Since I couldn't find any Perl example on the net to show usage of this library, I just want to check with you to see if I use this new() method correctly, or whether I need to supply any extra params/options into the new() method? Any insight is greatly appreciated. The error says:
Can't connect to myK8Scluster:8443 Trace begun at /opt/ActivePerl-5.28/lib/perl5/site_perl/5.28.1/Net/Kub +ernetes/Role/ResourceLister.pm line 42

Replies are listed 'Best First'.
Re: Perl's Net:Kubernetes question
by syphilis (Archbishop) on Nov 13, 2019 at 02:56 UTC
    Can't connect to myK8Scluster:8443

    The Net-Kubenetes documentation states that those SSL options "are basically just a passthrough to the underlying LWP::UserAgent used to handle the api requests".
    And the LWP::UserAgent documentation says "the libwww-perl core no longer bundles protocol plugins for SSL. You will need to install LWP::Protocol::https separately to enable support for processing https-URLs".

    So I would first install LWP::Protocol::https if it's not already, and see if that helps.
    The LWP::UserAgent documentation makes reference to IO::Socket::SSL and Net::SSL modules, so I'm thinking you might also need at least one of those two installed.

    Cheers,
    Rob
      Hi Rob, thanks for the pointers. I checked and my Perl install already has LWP::UserAgent, LWP::Protocol::https, and IO::Socket::SSL installed. The only missing one is Net::SSL. Are both IO::Socket::SSL AND Net::SSL required, or having one installed is sufficient?

        If you just want to confirm that your LWP::UserAgent can make an https connection try this from your shell:

        HEAD https://www.google.com/

        If the first line returned is 200 OK then you are good to go.