<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Efkan Isazade</title>
    <description>The latest articles on DEV Community by Efkan Isazade (@efe136).</description>
    <link>https://dev.to/efe136</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F254035%2F108c271a-4b56-43e8-844a-a7e27a0f42d7.png</url>
      <title>DEV Community: Efkan Isazade</title>
      <link>https://dev.to/efe136</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/efe136"/>
    <language>en</language>
    <item>
      <title>Automating Ubuntu-20.04 live-server template generation with packer vsphere-iso build.</title>
      <dc:creator>Efkan Isazade</dc:creator>
      <pubDate>Sun, 10 Jan 2021 16:15:13 +0000</pubDate>
      <link>https://dev.to/efe136/automating-ubuntu-20-04-live-server-template-generation-with-packer-vsphere-iso-build-3hla</link>
      <guid>https://dev.to/efe136/automating-ubuntu-20-04-live-server-template-generation-with-packer-vsphere-iso-build-3hla</guid>
      <description>&lt;p&gt;Ubuntu is discontinuing support for the Debian-installer (preseed). Ubuntu Server 20.04 comes with a new automated OS installation method called autoinstall with subiquity server installer. This post shows packer build with new installer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Update:
&lt;/h2&gt;

&lt;p&gt;This setup is only for Ubuntu-20.04 live-server not legacy.&lt;/p&gt;

&lt;h2&gt;
  
  
  subiquity
&lt;/h2&gt;

&lt;p&gt;Subiquity is the Ubuntu server’s new automated installer, which was introduced in 18.04. The setup for autoinstallation is given by the cloud-init configuration.&lt;br&gt;
If set, values will be taken from the config file, otherwise default values will be used. There are different ways of delivering cloud-init configuration.&lt;br&gt;
User configuration is usually contained in user-data and cloud configuration in meta-data files. &lt;br&gt;
For more detailed info you can look &lt;strong&gt;&lt;a href="https://ubuntu.com/server/docs/install/autoinstall"&gt;The AutoInstall documentation provided by Canonical&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Our installer is based on curtin, netplan and cloud-init.&lt;/p&gt;
&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;user-data&lt;/li&gt;
&lt;li&gt;packer file&lt;/li&gt;
&lt;li&gt;variable file&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Lets take a look one by one
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#cloud-config&lt;/span&gt;
autoinstall:
    version: 1
    early-commands:
        &lt;span class="c"&gt;# Stop ssh for packer&lt;/span&gt;
        - &lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl stop ssh
    locale: en_US
    keyboard:
        layout: en
        variant: us
    identity:
        &lt;span class="nb"&gt;hostname&lt;/span&gt;: ubuntu-server
        username: ubuntu
        password: &lt;span class="s1"&gt;'$6$rounds=4096$NYG7e8HxIMgz1$BqP28Ppt0FqXiBQuiE6PxiVBJJJAbm8tJrNz4HC7MEC.7Gv/eOyQIfaLqZ6W6fnMMtxP.BYfHmTBxUFQQs0u91'&lt;/span&gt;
    ssh:
        install-server: &lt;span class="nb"&gt;yes
        &lt;/span&gt;allow-pw: &lt;span class="nb"&gt;yes
    &lt;/span&gt;storage:
        layout:
            name: direct
    apt:
        primary:
            - arches: &lt;span class="o"&gt;[&lt;/span&gt;i386, amd64]
              uri: &lt;span class="s2"&gt;"http://ro.archive.ubuntu.com/ubuntu/"&lt;/span&gt;
    user-data:
      disable_root: &lt;span class="nb"&gt;false
    &lt;/span&gt;late-commands:
      - &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'s/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g'&lt;/span&gt; /target/etc/ssh/sshd_config
      - &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'s/^#\?PermitRootLogin.*/PermitRootLogin yes/g'&lt;/span&gt; /target/etc/ssh/sshd_config
      - &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'ubuntu ALL=(ALL) NOPASSWD:ALL'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /target/etc/sudoers.d/ubuntu
      - curtin &lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="nt"&gt;-target&lt;/span&gt; &lt;span class="nt"&gt;--target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/target &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nb"&gt;chmod &lt;/span&gt;440 /etc/sudoers.d/ubuntu
      - curtin &lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="nt"&gt;-target&lt;/span&gt; &lt;span class="nt"&gt;--target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/target &lt;span class="nt"&gt;--&lt;/span&gt; apt-get update
      - curtin &lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="nt"&gt;-target&lt;/span&gt; &lt;span class="nt"&gt;--target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/target &lt;span class="nt"&gt;--&lt;/span&gt; apt-get upgrade &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;As you see it is &lt;code&gt;.yaml&lt;/code&gt; formatted config. We have specifeied all the details (what we need otherwise will use default) in this config. But we need to understand some tricky parts.&lt;br&gt;
Firstly on &lt;code&gt;identity&lt;/code&gt; part as you see we have used hashed password. It is default requirement of autoinstaller for security purpose. Actually we need more for deeply secure system but at that moment it is okay. But how we generate this hashed password ?&lt;br&gt;
Actually I used &lt;code&gt;ubuntu&lt;/code&gt; as the password for ssh connection and for making it hashed I used below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkpasswd &lt;span class="nt"&gt;-m&lt;/span&gt; SHA-512 &lt;span class="nt"&gt;--rounds&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now lets move a little bit up and find out &lt;code&gt;early-commands&lt;/code&gt;. What it means? Actually when we start packer build, packer try to set ssh connection from the beginning to our machine. So During initialization it could gives us error can break the build. So at the first stage we need to be sure that our ssh connection is stopped.&lt;br&gt;
For understanding all the parts you can look &lt;strong&gt;&lt;a href="https://ubuntu.com/server/docs/install/autoinstall-reference"&gt;Ubuntu Autoinstall Reference&lt;/a&gt;&lt;/strong&gt;. Fortunately documentation are very simple and useful provided by Canonical.&lt;/p&gt;

&lt;p&gt;Now we need to create meta-data file. But we will keep it empty. At last we need to create &lt;code&gt;http&lt;/code&gt; directory and put these files into it.&lt;/p&gt;

&lt;p&gt;Now we need to define our packer file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"builders"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"CPUs"&lt;/span&gt;: 2,
      &lt;span class="s2"&gt;"RAM"&lt;/span&gt;: 2048,
      &lt;span class="s2"&gt;"RAM_reserve_all"&lt;/span&gt;: &lt;span class="nb"&gt;true&lt;/span&gt;,
      &lt;span class="s2"&gt;"firmware"&lt;/span&gt;: &lt;span class="s2"&gt;"bios"&lt;/span&gt;,
      &lt;span class="s2"&gt;"boot_command"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
         &lt;span class="s2"&gt;"&amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt;&amp;lt;esc&amp;gt;"&lt;/span&gt;,
         &lt;span class="s2"&gt;"&amp;lt;enter&amp;gt;&amp;lt;wait&amp;gt;"&lt;/span&gt;,
         &lt;span class="s2"&gt;"/casper/vmlinuz "&lt;/span&gt;,
         &lt;span class="s2"&gt;"root=/dev/sr0 "&lt;/span&gt;,
         &lt;span class="s2"&gt;"initrd=/casper/initrd "&lt;/span&gt;,
         &lt;span class="s2"&gt;"autoinstall "&lt;/span&gt;,
         &lt;span class="s2"&gt;"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"&lt;/span&gt;,
         &lt;span class="s2"&gt;"&amp;lt;enter&amp;gt;"&lt;/span&gt;
      &lt;span class="o"&gt;]&lt;/span&gt;,
      &lt;span class="s2"&gt;"boot_wait"&lt;/span&gt;: &lt;span class="s2"&gt;"2s"&lt;/span&gt;,
      &lt;span class="s2"&gt;"convert_to_template"&lt;/span&gt;: &lt;span class="s2"&gt;"true"&lt;/span&gt;,
      &lt;span class="s2"&gt;"create_snapshot"&lt;/span&gt;: &lt;span class="s2"&gt;"false"&lt;/span&gt;,
      &lt;span class="s2"&gt;"datacenter"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_datacenter&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"datastore"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_datastore&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"disk_controller_type"&lt;/span&gt;: &lt;span class="s2"&gt;"pvscsi"&lt;/span&gt;,
      &lt;span class="s2"&gt;"folder"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_folder&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"guest_os_type"&lt;/span&gt;: &lt;span class="s2"&gt;"ubuntu64Guest"&lt;/span&gt;,
      &lt;span class="s2"&gt;"host"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_host&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"http_directory"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;http_directory&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"insecure_connection"&lt;/span&gt;: &lt;span class="s2"&gt;"true"&lt;/span&gt;,
      &lt;span class="s2"&gt;"iso_checksum"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;iso_checksum_type&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}:{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;iso_checksum&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"iso_paths"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;iso_paths&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"name"&lt;/span&gt;: &lt;span class="s2"&gt;"Ubuntu-20.04"&lt;/span&gt;,
      &lt;span class="s2"&gt;"network_adapters"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
        &lt;span class="o"&gt;{&lt;/span&gt;
          &lt;span class="s2"&gt;"network"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_network&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
          &lt;span class="s2"&gt;"network_card"&lt;/span&gt;: &lt;span class="s2"&gt;"vmxnet3"&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;]&lt;/span&gt;,
      &lt;span class="s2"&gt;"notes"&lt;/span&gt;: &lt;span class="s2"&gt;"Default SSH User: {{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;ssh_username&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Default SSH Pass: {{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;ssh_password&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Built by Packer @ {{isotime &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;2006-01-02 03:04&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;}}."&lt;/span&gt;,
      &lt;span class="s2"&gt;"password"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_password&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"shutdown_command"&lt;/span&gt;: &lt;span class="s2"&gt;"echo 'ubuntu'|sudo -S shutdown -P now"&lt;/span&gt;,
      &lt;span class="s2"&gt;"ssh_password"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;ssh_password&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"ssh_timeout"&lt;/span&gt;: &lt;span class="s2"&gt;"20m"&lt;/span&gt;,
      &lt;span class="s2"&gt;"ssh_handshake_attempts"&lt;/span&gt;: &lt;span class="s2"&gt;"100000"&lt;/span&gt;,
      &lt;span class="s2"&gt;"ssh_username"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;ssh_username&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"storage"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
        &lt;span class="o"&gt;{&lt;/span&gt;
          &lt;span class="s2"&gt;"disk_size"&lt;/span&gt;: 20480,
          &lt;span class="s2"&gt;"disk_thin_provisioned"&lt;/span&gt;: &lt;span class="nb"&gt;true&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;]&lt;/span&gt;,
      &lt;span class="s2"&gt;"type"&lt;/span&gt;: &lt;span class="s2"&gt;"vsphere-iso"&lt;/span&gt;,
      &lt;span class="s2"&gt;"username"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_username&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"vcenter_server"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vcenter_server&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;,
      &lt;span class="s2"&gt;"vm_name"&lt;/span&gt;: &lt;span class="s2"&gt;"{{user &lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;vm_name&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="s2"&gt;}}"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;]&lt;/span&gt;,
  &lt;span class="s2"&gt;"provisioners"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
       &lt;span class="s2"&gt;"type"&lt;/span&gt;: &lt;span class="s2"&gt;"shell"&lt;/span&gt;,
       &lt;span class="s2"&gt;"execute_command"&lt;/span&gt;: &lt;span class="s2"&gt;"echo 'ubuntu' | {{.Vars}} sudo -S -E bash '{{.Path}}'"&lt;/span&gt;,
       &lt;span class="s2"&gt;"script"&lt;/span&gt;: &lt;span class="s2"&gt;"scripts/setup_ubuntu2004.sh"&lt;/span&gt;
     &lt;span class="o"&gt;}&lt;/span&gt;
   &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I need mention some tricky points now. So as you see I used &lt;code&gt;user&lt;/code&gt; keyword on packer file. It is for defining variable. Another most important part is &lt;code&gt;ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/&lt;/code&gt;.&lt;br&gt;
So what it means ? As you remember I created http directory and put config files into it. So we need a web server to serve these files in order packer use them during build process.&lt;br&gt;
When the build is executed, Packer will launch a small HTTP server and replace the &lt;code&gt;{{.HTTPIP}}&lt;/code&gt; and &lt;code&gt;{.HTTPPort}}&lt;/code&gt; variables with the respective IP and port.&lt;br&gt;
You must also set the &lt;code&gt;http_directory&lt;/code&gt; (I already defined in packer file) configuration option to define which directory hosts the files that you want to be served by the HTTP server on your filesystem. &lt;br&gt;
Bu as you wish you can also serve your files with different ways. For example I have uploaded config files to my custom static server and served through this server. I mean instead of &lt;code&gt;http://{{ .HTTPIP }}:{{ .HTTPPort }}/&lt;/code&gt; I used my own server &lt;code&gt;https://ubuntu-cloud-init.vercel.app/&lt;/code&gt; for my enterprise configuration.&lt;/p&gt;

&lt;p&gt;At least we need to define variable file. Here is mine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"vm_name"&lt;/span&gt;: &lt;span class="s2"&gt;"Ubuntu-2004-Template"&lt;/span&gt;,  
  &lt;span class="s2"&gt;"vcenter_server"&lt;/span&gt;:&lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"vcenter_username"&lt;/span&gt;:&lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"vcenter_password"&lt;/span&gt;:&lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"vcenter_datacenter"&lt;/span&gt;: &lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"vcenter_datastore"&lt;/span&gt;: &lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"vcenter_host"&lt;/span&gt;: &lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"vcenter_folder"&lt;/span&gt;: &lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"vcenter_network"&lt;/span&gt;: &lt;span class="s2"&gt;""&lt;/span&gt;,
  &lt;span class="s2"&gt;"guest_os_type"&lt;/span&gt;: &lt;span class="s2"&gt;"ubuntu64Guest"&lt;/span&gt;,
  &lt;span class="s2"&gt;"http_directory"&lt;/span&gt;: &lt;span class="s2"&gt;"http"&lt;/span&gt;,
  &lt;span class="s2"&gt;"iso_urls"&lt;/span&gt;: &lt;span class="s2"&gt;"https://releases.ubuntu.com/focal/ubuntu-20.04.1-live-server-amd64.iso"&lt;/span&gt;,
  &lt;span class="s2"&gt;"iso_checksum_type"&lt;/span&gt;: &lt;span class="s2"&gt;"sha256"&lt;/span&gt;,
  &lt;span class="s2"&gt;"iso_checksum"&lt;/span&gt;: &lt;span class="s2"&gt;"443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93"&lt;/span&gt;,
  &lt;span class="s2"&gt;"iso_paths"&lt;/span&gt;: &lt;span class="s2"&gt;"[Datastore VMS] /packer_cache/ubuntu-20.04.1-live-server-amd64.iso"&lt;/span&gt;,
  &lt;span class="s2"&gt;"ssh_username"&lt;/span&gt;: &lt;span class="s2"&gt;"ubuntu"&lt;/span&gt;,
  &lt;span class="s2"&gt;"ssh_password"&lt;/span&gt;: &lt;span class="s2"&gt;"ubuntu"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use your own custom details for empty &lt;code&gt;vcenter&lt;/code&gt; variables.&lt;br&gt;
I have used &lt;code&gt;iso_path&lt;/code&gt; variable on packer file. But Also I have added &lt;code&gt;iso_url&lt;/code&gt; variable to variable file. So If you dont have ready Ubuntu-20.04 live-server then you can basically change &lt;code&gt;iso_path&lt;/code&gt; variable with &lt;code&gt;iso_url&lt;/code&gt; in packer file.&lt;/p&gt;

&lt;p&gt;This builds a VM Template in vSphere based on Ubuntu 20.04, with a predefined ubuntu/ubuntu user. Although this image is still really helpful, I would like to add another phase to my image.&lt;br&gt;
I plan to use this image with Rancher's vSphere Provisioner which means I need the datasource for vSphere cloud-init. It's available here as a &lt;strong&gt;&lt;a href="https://github.com/vmware/cloud-init-vmware-guestinfo"&gt;plugin&lt;/a&gt;&lt;/strong&gt;.&lt;br&gt;
So I added a script in &lt;code&gt;provisioners&lt;/code&gt; line in packer file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="s2"&gt;"provisioners"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
       &lt;span class="s2"&gt;"type"&lt;/span&gt;: &lt;span class="s2"&gt;"shell"&lt;/span&gt;,
       &lt;span class="s2"&gt;"execute_command"&lt;/span&gt;: &lt;span class="s2"&gt;"echo 'ubuntu' | {{.Vars}} sudo -S -E bash '{{.Path}}'"&lt;/span&gt;,
       &lt;span class="s2"&gt;"script"&lt;/span&gt;: &lt;span class="s2"&gt;"scripts/setup_ubuntu2004.sh"&lt;/span&gt;
     &lt;span class="o"&gt;}&lt;/span&gt;
   &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets up the datasource and resets the machine id to reset the state of the machine. You can find both packer file and configs and also script from my github &lt;strong&gt;&lt;a href="https://github.com/efe136/packer-ubuntu20.04"&gt;repo&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to solve VMware ESXI /var partition ramdisk full issue ?</title>
      <dc:creator>Efkan Isazade</dc:creator>
      <pubDate>Sun, 10 Jan 2021 16:11:06 +0000</pubDate>
      <link>https://dev.to/efe136/how-to-solve-vmware-esxi-var-partition-ramdisk-full-issue-3c5a</link>
      <guid>https://dev.to/efe136/how-to-solve-vmware-esxi-var-partition-ramdisk-full-issue-3c5a</guid>
      <description>&lt;p&gt;The full /var partition on the ESXI host can trigger host problems. If you keep the /var partition free of space the hosts will be running well in your cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing of the root cause of the runaway log file
&lt;/h2&gt;

&lt;p&gt;When the issue was presented, I wasn't able to connect with any terminal app to hosts so, I had to use the host console. And after a while found that the &lt;code&gt;/var/log/EMU/mili/mili2d.log&lt;/code&gt; was continually growing.&lt;br&gt;
In the vsphere syslog found this error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;The ramdisk 'var' is full. As a result, the file `/var/log/EMU/mili/mili2d.log` could not be written.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I looked &lt;code&gt;/var/log/EMU/mili/mili2d.log&lt;/code&gt; and revealed following errors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;CRITICAL:backend_init:OneConnect Adapter Not Found.
ERROR:rename all the configuration files!
ERROR:MILI_enumerate_elxiscsi:Failed to initialize User Init with status = 19
ERROR:MILI_enumerate_elx_nics:Failed to initialize USer Init with status = 19
ERROR:could not open device node /vmfs/devices/char/vmkdriver/be_esx_nic
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What it means ? &lt;/p&gt;

&lt;p&gt;Since both servers do not have any Emulex hardware installed, the elxnet drivers are not needed. So I removed them and rebooted hosts. That is it, It solved my problem on the hosts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;esxcli software vib remove --vibname elxnet
esxcli software vib remove --vibname elxiscsi
esxcli software vib remove --vibname elx-esx-libelxima.so
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to enable Gitlab Container Registry with Minio custom S3 Bucket ? Part 2</title>
      <dc:creator>Efkan Isazade</dc:creator>
      <pubDate>Sun, 10 Jan 2021 15:58:47 +0000</pubDate>
      <link>https://dev.to/efe136/how-to-enable-gitlab-container-registry-with-minio-custom-s3-bucket-part-2-4180</link>
      <guid>https://dev.to/efe136/how-to-enable-gitlab-container-registry-with-minio-custom-s3-bucket-part-2-4180</guid>
      <description>&lt;p&gt;By default there is a setup may or may not enabled gitlab &lt;/p&gt;

&lt;p&gt;In this part we will setup container registry inside self hosted gitlab with Openssl based self genrated ssl. If you wish you can read &lt;a href="https://efkan-isazade.com/gitlab-container-registry"&gt;Part1&lt;/a&gt;. Lets get started.&lt;br&gt;
First we need generate SSL cert with Openssl in our gitlab server.&lt;/p&gt;
&lt;h2&gt;
  
  
  Certificate authority (CA)
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;openssl req -x509 -nodes -new -sha256 -days 1024 -newkey rsa:2048 -keyout RootCA.key -out RootCA.pem -subj "/C=US/CN=Example-Root-CA"
openssl x509 -outform pem -in RootCA.pem -out RootCA.crt
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Example-Root-CA is an example, you can customize the name.&lt;/p&gt;
&lt;h2&gt;
  
  
  Domain name certificate
&lt;/h2&gt;

&lt;p&gt;Let's say we have two domains gitlab.local and registry.gitlab.local that are hosted on your local machine.&lt;/p&gt;

&lt;p&gt;First, create a file domains.ext that lists all your local domains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = gitlab.local
DNS.3 = registry.gitlab.local
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to generate localhost.key, localhost.csr, and localhost.crt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;openssl req -new -nodes -newkey rsa:2048 -keyout localhost.key -out localhost.csr -subj "/C=US/ST=YourState/L=YourCity/O=Example-Certificates/CN=localhost.local"
openssl x509 -req -sha256 -days 1024 -in localhost.csr -CA RootCA.pem -CAkey RootCA.key -CAcreateserial -extfile domains.ext -out localhost.crt
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The country / state / city / name in the first command can be changed.&lt;/p&gt;

&lt;p&gt;Now we can setup registry inside gitlab.&lt;/p&gt;

&lt;h2&gt;
  
  
  Registry setup
&lt;/h2&gt;

&lt;p&gt;First we need to locate ssl cert and key in &lt;code&gt;/etc/gitlab/ssl&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;mv ./localhost.crt /etc/gitlab/ssl
mv ./localhost.key /etc/gitlab/ssl
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s open up our &lt;code&gt;/etc/gitlab/gitlab.rb&lt;/code&gt; file and modify.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="c"&gt;...
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;###############################################################################&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;# Container Registry settings&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;#! Docs: https://docs.gitlab.com/ce/administration/container_registry.html&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;###############################################################################&lt;/span&gt;
&lt;span class="go"&gt;
registry_external_url 'https://registry.gitlab.local:5050'

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;#c Settings used by GitLab application&lt;/span&gt;
&lt;span class="go"&gt;gitlab_rails['registry_enabled'] = true
gitlab_rails['registry_host'] = "registry.gitlab.local"
gitlab_rails['registry_port'] = "5050"
gitlab_rails['registry_path'] = "/var/opt/gitlab/gitlab-rails/shared/registry"

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;##! **Do not change the following 3 settings unless you know what you are&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;##!   doing**&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gitlab_rails[&lt;span class="s1"&gt;'registry_api_url'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:5000"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gitlab_rails[&lt;span class="s1"&gt;'registry_key_path'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/var/opt/gitlab/gitlab-rails/certificate.key"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gitlab_rails[&lt;span class="s1"&gt;'registry_issuer'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"omnibus-gitlab-issuer"&lt;/span&gt;
&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;## Settings used by Registry application&lt;/span&gt;
&lt;span class="go"&gt;registry['enable'] = true
registry['health_storagedriver_enabled'] = false
registry_nginx['ssl_certificate'] = "/etc/gitlab/ssl/localhost.crt"
registry_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/localhost.key"
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'username'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"registry"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'group'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"registry"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'uid'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; nil
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'gid'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; nil
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'dir'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/var/opt/gitlab/registry"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'registry_http_addr'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"localhost:5000"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'debug_addr'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"localhost:5001"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'log_directory'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/var/log/gitlab/registry"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'env_directory'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/opt/gitlab/etc/registry/env"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'env'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="s1"&gt;'SSL_CERT_DIR'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"/opt/gitlab/embedded/ssl/certs/"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'log_level'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"info"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'log_formatter'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"text"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'rootcertbundle'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/var/opt/gitlab/registry/certificate.crt"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'health_storagedriver_enabled'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'storage_delete_enabled'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'validation_enabled'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'autoredirect'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;registry[&lt;span class="s1"&gt;'compatibility_schema1_enabled'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;
&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;## Registry backend storage&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="c"&gt;##! Docs: https://docs.gitlab.com/ce/administration/container_registry.html#container-registry-storage-driver&lt;/span&gt;
&lt;span class="go"&gt;registry['storage'] = {
&lt;/span&gt;&lt;span class="gp"&gt;  's3' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="gp"&gt;    'accesskey' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'minio'&lt;/span&gt;,
&lt;span class="gp"&gt;    'secretkey' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'miniostorage'&lt;/span&gt;,
&lt;span class="gp"&gt;    'bucket' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'gitlab-registry'&lt;/span&gt;,
&lt;span class="gp"&gt;    'region' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'us-east-1'&lt;/span&gt;,
&lt;span class="gp"&gt;    'regionendpoint' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'http://minio.example.com:9000'&lt;/span&gt;,
&lt;span class="gp"&gt;    'secure' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;,
&lt;span class="gp"&gt;    'encrypt' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;,
&lt;span class="gp"&gt;    'v4Auth' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="go"&gt;  },
&lt;/span&gt;&lt;span class="gp"&gt;  'redirect' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="gp"&gt;     'disable' =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="go"&gt;  }
}
&lt;/span&gt;&lt;span class="c"&gt;...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I should explain something in this setup.&lt;br&gt;
First off all when we create this setup we have to look if registry storage health check is enabled. We should first make it false if our minio bucket is free. It is a bug and only solution is make storage health check false. After all done you installed image to bucket you can then make health check enable.&lt;br&gt;
Another thing is about registry s3 setup. We should define region as like in aws s3, without it gitlab will give us an exception. You can set any region as you wish and it doesnt matter.&lt;br&gt;
For bucket it is the bucket that you generated in your minio s3 server.&lt;br&gt;
Next thing is about nginx setup. Normally nginx setup for registry is located in the down of the gitlab.rb but for not to copying all the setup I have added it to registry setup.&lt;/p&gt;

&lt;p&gt;Now we need to reconfigure gitlab setup. It will not affect anything in your current setup. It will only restart config for gilab.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;gitlab-ctl reconfigure
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is it. Now we can login our registry from docker server and push images there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;docker login registry.gitlab.local:5050
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get output like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
Login Succeeded
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then it means you are ready to push your images to custom made registry. That is it for now. If you have any problem with this setup please let me know with contact form. Thank you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to enable Gitlab Container Registry with Minio custom S3 Bucket ? Part1
</title>
      <dc:creator>Efkan Isazade</dc:creator>
      <pubDate>Mon, 16 Nov 2020 15:06:21 +0000</pubDate>
      <link>https://dev.to/efe136/how-to-enable-gitlab-container-registry-with-minio-custom-s3-bucket-part1-3d3o</link>
      <guid>https://dev.to/efe136/how-to-enable-gitlab-container-registry-with-minio-custom-s3-bucket-part1-3d3o</guid>
      <description>&lt;h3&gt;
  
  
  By default there is a setup may or may not enabled gitlab registry in Gitlab Omnibus. In this Post you will learn how to enable it and integrate with Minio S3 bucket. In this Part1 we will install and configure Minio server.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Pre-requisites
&lt;/h3&gt;

&lt;p&gt;For this setup we need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gitlab Omnibus Server (ce, ee)&lt;/li&gt;
&lt;li&gt;Ubuntu 20.04 Server (minimum 4gb ram, 4 cpu, and 250 gb storage)&lt;/li&gt;
&lt;li&gt;Docker server to test Gitlab container registry&lt;/li&gt;
&lt;li&gt;Openssl or Letsencrypt for secure connection&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Minio installation
&lt;/h2&gt;

&lt;p&gt;You can install the Minio server by compiling the source code or via a binary file. To install it from the source, you need to have at least Go 1.12 installed on your system.&lt;br&gt;
First, log in to your server, replacing efe with your username and your_server_ip with your Ubuntu 20.04 server’s IP address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;ssh efe@your_server_ip
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you have to update package database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo apt update
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, download the Minio server’s binary file from the official website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;wget https://dl.min.io/server/minio/release/linux-amd64/minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be similar:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
--2020-07-31 15:08:49--  https://dl.min.io/server/minio/release/linux-amd64/minio
Resolving dl.min.io (dl.min.io)... 178.128.69.202
Connecting to dl.min.io (dl.min.io)|178.128.69.202|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44511616 (42M) [application/octet-stream]
Saving to: ‘minio’

&lt;/span&gt;&lt;span class="gp"&gt;minio               100%[===================&amp;gt;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  42.45M  21.9MB/s    &lt;span class="k"&gt;in &lt;/span&gt;1.9s
&lt;span class="go"&gt;
2020-07-31 15:08:51 (21.9 MB/s) - ‘minio’ saved [44511616/44511616]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the download is finished, a file named minio will be in your working directory. By the following command to make it executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo chmod +x minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next move the file into the /usr/local/bin directory that Minio’s systemd startup script expects to find it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo mv minio /usr/local/bin
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For security reason it is the best practice to avoid Minio server running as root. So we need to create minio user and group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo useradd -r minio-user -s /sbin/nologin
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, change ownership of the Minio binary to minio-user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo chown minio-user:minio-user /usr/local/bin/minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we need to create a directory where Minio will store files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo mkdir /usr/local/share/minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to give ownership of minio-user to this directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo chown minio-user:minio-user /usr/local/share/minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to create directory inside /etc in order to store Minio configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo mkdir /etc/minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then again give ownership of mini-user too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo chown minio-user:minio-user /etc/minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to add and modify minio default configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;vim /etc/default/minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the file is open, add in the following lines to set some important environment variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;MINIO_ACCESS_KEY="minio"
MINIO_VOLUMES="/usr/local/share/minio/"
MINIO_OPTS="-C /etc/minio --address your_server_ip:9000"
MINIO_SECRET_KEY="miniostorage"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to change the variables with your own.&lt;/p&gt;

&lt;p&gt;Now it is the time to install Minio Systemd Startup Script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;curl -O https://raw.githubusercontent.com/minio/minio-service/master/linux-systemd/minio.service
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be similar to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   835  100   835    0     0   6139      0 --:--:-- --:--:-- --:--:--  6139
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to audit the contents of minio.service before applying it, open it in a text editor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;vim minio.service
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will show the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio

[Service]
WorkingDirectory=/usr/local/

User=minio-user
Group=minio-user

EnvironmentFile=/etc/default/minio
&lt;/span&gt;&lt;span class="gp"&gt;ExecStartPre=/bin/bash -c "if [ -z \"$&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;MINIO_VOLUMES&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="se"&gt;\"&lt;/span&gt;Variable MINIO_VOLUMES not &lt;span class="nb"&gt;set &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; /etc/default/minio&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit &lt;/span&gt;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;&lt;span class="s2"&gt;"
&lt;/span&gt;&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;ExecStart=/usr/local/bin/minio server $&lt;/span&gt;MINIO_OPTS &lt;span class="nv"&gt;$MINIO_VOLUMES&lt;/span&gt;
&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Let systemd restart this service always
&lt;span class="go"&gt;Restart=always

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Specifies the maximum file descriptor number that can be opened by this process
&lt;span class="go"&gt;LimitNOFILE=65536

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Disable &lt;span class="nb"&gt;timeout &lt;/span&gt;logic and &lt;span class="nb"&gt;wait &lt;/span&gt;&lt;span class="k"&gt;until &lt;/span&gt;process is stopped
&lt;span class="go"&gt;TimeoutStopSec=infinity
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Built &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;project&lt;/span&gt;&lt;span class="p"&gt;.name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;-&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;project&lt;/span&gt;&lt;span class="p"&gt;.version&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;project&lt;/span&gt;&lt;span class="p"&gt;.name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to change unit files directories. Systemd requires that unit files be stored in the systemd configuration directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo mv minio.service /etc/systemd/system
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we need to run the following commands to reload all systemd units and enable Minio to start on boot and start Minio:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo systemctl daemon-reload
sudo systemctl enable minio
sudo systemctl start minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will use default 9000 port on Minio server. So for that we need to enable access configured port through firewall:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo ufw allow 9000
sudo ufw enable
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get the following prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
Command may disrupt existing ssh connections. Proceed with operation (y|n)?
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press y and ENTER to confirm this. Output should be like following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
Firewall is active and enabled on system startup
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our Minio server is ready to accept traffic but in order to make it secure, we need another step to configure Let’s Encrypt(it is free to use) ssl to our Minio server:&lt;/p&gt;

&lt;p&gt;First, allow HTTP and HTTPS access through firewall.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo ufw allow 80
sudo ufw allow 443
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once all done we can check status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo ufw status verbose
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output should be like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22/tcp (OpenSSH)           ALLOW IN    Anywhere
9000                       ALLOW IN    Anywhere
443                        ALLOW IN    Anywhere
80                         ALLOW IN    Anywhere
22/tcp (OpenSSH (v6))      ALLOW IN    Anywhere (v6)
9000 (v6)                  ALLOW IN    Anywhere (v6)
443 (v6)                   ALLOW IN    Anywhere (v6)
80 (v6)                    ALLOW IN    Anywhere (v6)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we will install Certbot. Before generating free wildcard certificates, we need first to make sure certbot is installed and running… To install it, run the commands below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo apt update
sudo apt-get install letsencrypt
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can obtain certificate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo certbot certonly --standalone -d minio-server.your_domain
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output should be like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add your email and press ENTER.&lt;/p&gt;

&lt;p&gt;Will then ask you to register with Let’s Encrypt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel:
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Type A and press ENTER to agree.&lt;/p&gt;

&lt;p&gt;Next you will see this output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Output
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can answer it yourself both Y or N, then your public and private keys will be generated and saved in the /etc/letsencrypt/live/minio-server.your_domain_name directory.&lt;/p&gt;

&lt;p&gt;Next, we need to copy two files (privkey.pem and fullchain.pem) into the certs directory under Minio’s server configuration folder and rename it to private.key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo cp /etc/letsencrypt/live/minio-server.your_domain_name/privkey.pem /etc/minio/certs/private.key
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then do the same for fullchain.pem, naming rename public.crt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo cp /etc/letsencrypt/live/minio-server.your_domain_name/fullchain.pem /etc/minio/certs/public.crt
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to change ownership of private.key and public.crt to mini-user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo chown minio-user:minio-user /etc/minio/certs/private.key
sudo chown minio-user:minio-user /etc/minio/certs/public.crt
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before connect Minio server Web interface, we need to restart it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sudo systemctl restart minio
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At last we can Access the web interface by pointing to &lt;a href="https://minio-server.your_domain:9000" rel="noopener noreferrer"&gt;https://minio-server.your_domain:9000&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You will see login screen like that:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbq28y5vgwnl1k671rouh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbq28y5vgwnl1k671rouh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, log in to the main interface by entering credentials.(MINIO_ACCESS_KEY, MINIO_SECRET_KEY)&lt;/p&gt;

&lt;p&gt;Then you can create bucket through:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8t3o5e932fnwutryivtp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8t3o5e932fnwutryivtp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is it for now... Follow for next Part2. I will share how to connect Gitlab container registry to Minio bucket.&lt;/p&gt;

</description>
      <category>gitlab</category>
      <category>minio</category>
    </item>
    <item>
      <title>How to enable MongoDB authentication with docker-compose ?</title>
      <dc:creator>Efkan Isazade</dc:creator>
      <pubDate>Thu, 21 May 2020 08:23:53 +0000</pubDate>
      <link>https://dev.to/efe136/how-to-enable-mongodb-authentication-with-docker-compose-2nbp</link>
      <guid>https://dev.to/efe136/how-to-enable-mongodb-authentication-with-docker-compose-2nbp</guid>
      <description>&lt;p&gt;By default there is no authentication in MongoDB. It means that it comes with empty authentication. So we should create users and roles manually. There are lots of ways to create MongoDB docker-compose with authentication. The most popular one of them is to write a bash script with user and roles then use it in docker-compose and another way is to create an init-mongodb.js file with users and roles and use it in docker-compose. But in this post, I will show you how you could create MongoDB docker-compose and then add users and roles manually. Lets start...&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Run MongoDB docker-compose without authentication&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;First of all we should run MongoDB &lt;code&gt;docker-compose&lt;/code&gt; without auth. Using &lt;code&gt;docker-compose up -d&lt;/code&gt; we could run it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yezN4R8G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uqd2xlbe7m5mmzlglebp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yezN4R8G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uqd2xlbe7m5mmzlglebp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Connect MongoDB without auth inside container&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For doing that firstly we should run &lt;code&gt;docker exec -it mongodb bash&lt;/code&gt; and enter inside the container. Then simply run &lt;code&gt;mongo&lt;/code&gt; command to connect to mongodb.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create user and roles for our MongoDB&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Firstly we will create admin user with username root and password root in admin database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M6-Mj7_n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yvuxdragqm624yqrwj3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M6-Mj7_n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yvuxdragqm624yqrwj3n.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we need to create other user. Here I will create a demo user within demo database for our MongoDB:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8JH0ACXd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ac3bqz221coi4t74x1w3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8JH0ACXd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ac3bqz221coi4t74x1w3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we are ready to run MongoDB with auth.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Enable MongoDB auth in docker-compose&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In order to enable auth in MongoDB we will use &lt;code&gt;--auth&lt;/code&gt; flag in docker-compose. After that we could use &lt;code&gt;docker-compose up -d&lt;/code&gt; command again, to run MongoDB container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FpCDa7qX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u8e1j6l02m570wrsm4nw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FpCDa7qX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u8e1j6l02m570wrsm4nw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Connect MongoDB with defined authentication&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this step we can connect our db with defined authentication. Firstly again we need to run &lt;code&gt;docker exec -it mongodb bash&lt;/code&gt; command in order to enter inside the container. Now we are in so we can connect our db. Here I write 2 command one of them is to connect admin db and another one is to connect demo db.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mongo -u root -p root --authenticationDatabase admin&lt;/code&gt;&lt;br&gt;
&lt;code&gt;mongo -u demo -p demo12345 --authenticationDatabase demo&lt;/code&gt;&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>docker</category>
      <category>devops</category>
      <category>db</category>
    </item>
  </channel>
</rss>
