https://github.com/nmasse-itix/k8s-installation
Terraform resources for a Kubernetes lab
https://github.com/nmasse-itix/k8s-installation
Last synced: 2 months ago
JSON representation
Terraform resources for a Kubernetes lab
- Host: GitHub
- URL: https://github.com/nmasse-itix/k8s-installation
- Owner: nmasse-itix
- Created: 2022-05-27T16:16:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-30T15:34:58.000Z (about 3 years ago)
- Last Synced: 2025-02-12T11:16:29.744Z (4 months ago)
- Language: HCL
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenShift 4 Installation
## Pre-requisites
### On your local machine
Install Terraform.
```sh
cat > hashicorp.repo <<"EOF"
[hashicorp]
name=Hashicorp Stable - $basearch
baseurl=https://rpm.releases.hashicorp.com/RHEL/8/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://rpm.releases.hashicorp.com/gpg
EOF
sudo dnf config-manager --add-repo hashicorp.repo
sudo dnf -y install terraform
```Install the libvirt terraform provider.
```sh
curl -Lo /tmp/libvirt-provider.zip https://github.com/dmacvicar/terraform-provider-libvirt/releases/download/v0.6.14/terraform-provider-libvirt_0.6.14_linux_amd64.zip
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.14/linux_amd64
unzip -d ~/.terraform.d/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.14/linux_amd64 /tmp/libvirt-provider.zip
mv -i ~/.terraform.d/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.14/linux_amd64/terraform-provider-libvirt{_v0.6.14,}
```Create the template files from their samples.
```sh
cp terraform.tfvars.sample terraform.tfvars
cp local.env.sample local.env
```Install the required Ansible collections.
```sh
ansible-galaxy collection install -r ansible/requirements.yaml
```Initialize Terraform.
```sh
terraform init
```### On the server
Install libvirt.
```sh
sudo dnf install libvirt libvirt-daemon-kvm virt-install virt-viewer virt-top libguestfs-tools nmap-ncat
```Configure NetworkManager to use dnsmasq. In **/etc/NetworkManager/NetworkManager.conf**:
```ini
[main]
dns=dnsmasq
```Download the required images.
```sh
curl -Lo /var/lib/libvirt/images/base-images/focal-server-cloudimg-amd64.qcow2 https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
curl -Lo /var/lib/libvirt/images/base-images/centos-stream-8.qcow2 http://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20210210.0.x86_64.qcow2
```## Install
Initialize a new cluster.
```sh
./cluster init my-cluster
```Deploy the cluster.
```sh
./cluster apply my-cluster
```Do the post-install on the cluster.
```sh
./cluster post-install my-cluster
```