Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Kubernetes Installation and Configuration #20

Draft
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

Searge
Copy link
Collaborator

@Searge Searge commented Apr 15, 2024

Description:

  • This MR prepares infrastructure for Kubernetes installation. Key changes include:
    • Certificate generation: TLS certificates for secure Kubernetes communication.
    • Encryption: Configuration for encrypting sensitive Kubernetes data.
    • Kubeconfig setup: Authentication files for kube-proxy, kube-controller-manager, kube-scheduler, and the admin user.
    • Parallel VM operations: Speed up Vagrant provisioning.
    • kubectl installation: Add command-line management tool.
  • Dependency Updates:
    • Updated dependencies in both pyproject.toml and requirements.txt files to ensure compatibility and security.
  • SSH Configuration Updates:
    • Revised SSH configurations in the ssh.cfg file to use specific IP addresses instead of localhost for better clarity and consistency.

These changes collectively aim to enhance the project's compatibility, security, and maintainability.

- Added `service_cidr` variable with value "10.96.0.0/24" to `vagrant.yml` group_vars.
- Added `certs_path` variable with value "{{ ansible_user_dir }}/certs" to `vagrant.yml` group_vars.
- Added task to install latest stable version of kubectl using the ARCH variable from /etc/environment.
- Retrieved stable release version of kubectl from https://dl.k8s.io/release/stable.txt.
- Installed kubectl binary with appropriate permissions and mode.
- Printed the kubectl version.
- Added tasks to generate Certificate Authority (CA) and various client and server certificates.
- Generated private keys and CSR for admin user, kube-controller-manager, kube-proxy, kube-scheduler, kube-apiserver, kube-apiserver-kubelet-client, etcd-server, and service-account.
- Signed the certificates using the CA private key.
- Verified the PKI with cert_verify.sh.
- Moved certificate verification scripts cert_verify.sh and approve_csr.sh to the 'certs' directory for better organization.
- Renamed approve-csr.sh to approve_csr.sh for consistency.
@Searge Searge requested review from a team as code owners April 15, 2024 17:09
@Searge Searge changed the base branch from main to develop April 15, 2024 17:38
- Updated the SSH configurations in ssh.cfg to use specific IP addresses instead of localhost for better clarity and consistency.
- Commented out the Port directives in ssh.cfg since the default ports are used.
- Modified the 'up' task in Taskfile.dist.yml to include the '--parallel' flag for faster provisioning of VMs.
- Updated the 'destroy' task in Taskfile.dist.yml to remove the sed command and replaced it with a command to clear known_hosts file for improved reliability.
- Added "netaddr" to pyproject.toml as a new dependency.
- Added "netaddr" version 1.2.1 to requirements.txt to ensure consistency across environments.
- Updated the `certs_path` variable in the `vagrant.yml` group_vars file to point to the root directory instead of a subdirectory.
- Refactored TLS certificate provisioning tasks to use a centralized CA key and certificate.
- Updated the tasks to generate the CA private key and CSR with appropriate subject details.
- Adjusted the tasks to sign certificates with the CA key and certificate.
- Removed redundant tasks for creating directories for certificates.
- Updated references to the CA key, CSR, and certificate files accordingly.
- Corrected the destination path for the `approve-csr.sh` script in the Vagrantfile.
- Updated the file path to match the actual location of the script.
Searge and others added 3 commits April 17, 2024 08:58
This commit introduces changes to generate Certificate Authority (CA) and TLS certificates using Ansible.
It includes tasks to create private keys, certificate signing requests (CSRs), and sign certificates for various components:

- Admin user
- Kube-controller-manager
- Kube-proxy
- Kube-scheduler
- Kubernetes API Server
- API Server Kubelet Client
- ETCD Server
- Service Account

The certificates are generated successfully and can be found in the specified location.
A command `cert_verify.sh` is provided to verify the certificates.
This commit introduces a task to generate an encryption key and configuration for Kubernetes.
The encryption key is generated using a shell command and set as a fact.
Then, the encryption configuration file is created with the key injected.
This enhances Kubernetes secrets security.
This commit adds tasks to generate kubeconfig files for the kube-proxy, kube-controller-manager, kube-scheduler services, and the admin user.
The tasks set up the necessary configurations using kubectl commands and include embedding certificates, setting cluster information, server URLs, client credentials, and context details.
@Searge Searge changed the title Update Dependencies, SSH Configurations, and Certificate Provisioning Tasks Enable Kubernetes Installation and Configuration Apr 21, 2024
- Uses delegate_to and block for better organization
- Defines CA certificate location as a fact
- Generates kubeconfig files with templated cert paths
…, generating/distributing kubeconfig

- Creates playbooks for provisioning CA, generating TLS certificates, installing kubectl, and generating kubeconfig files
- Distributes certificates and kubeconfig files to control plane and worker nodes

Refs: https://github.com/kelseyhightower/kubernetes-the-hard-way
- Update `stop` task in Taskfile.dist.yml to halt Virtualbox VM without parallel option.
- Correct the command in `destroy` task of Taskfile.dist.yml to clear known_hosts file.
- Amend the sed commands in bump.sh to properly update version strings in project files.
- Provide instructions for reviewing and editing the generated CHANGELOG.md file before committing.
- Adjust commit message to reflect the changes made.
- Add variables for etcd configuration in ansible/inventory/group_vars/all.yml.
- Include tasks in ansible/k8s_install.yml for bootstrapping the etcd cluster.
- Add tasks in ansible/tasks/bootstrap_etcd.yml to set up etcd binaries, directories, certificates, and services.
- Provide a template for the etcd service file in ansible/templates/db/etcd.service.j2.
Copy link

sonarcloud bot commented Apr 22, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@Searge Searge marked this pull request as draft May 1, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant