-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(k8s-oidc): add bare-metal k8s oidc github pages
- Loading branch information
Showing
15 changed files
with
449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
# k8s_oidc_github_pages | ||
|
||
Fetch Kubernetes OpenID Configuration and JWKs keys and push and deploy them to GitHub Pages as static files. | ||
|
||
Grab the OIDC configuration file from K8s API server and push it into a | ||
GitHub repository with Pages enabled. | ||
|
||
This will ultimately result in serving static files from a public URL with TLS | ||
enabled. | ||
|
||
As a result, the administrator can set up trust relationship with other | ||
service providers, such as AWS, to allow pods inside the Kubernetes cluster | ||
access to third-party cloud services. | ||
|
||
Although this is tailored for K3d Kubernetes cluster, there is nothing stopping | ||
it from being used on other Kubernetes clusters. | ||
|
||
|
||
## Table of content | ||
|
||
- [Requirements](#requirements) | ||
- [Default Variables](#default-variables) | ||
- [k8s_oidc_github_pages_commit_email](#k8s_oidc_github_pages_commit_email) | ||
- [k8s_oidc_github_pages_commit_name](#k8s_oidc_github_pages_commit_name) | ||
- [k8s_oidc_github_pages_debug](#k8s_oidc_github_pages_debug) | ||
- [k8s_oidc_github_pages_environments](#k8s_oidc_github_pages_environments) | ||
- [k8s_oidc_github_pages_github_deploy_key](#k8s_oidc_github_pages_github_deploy_key) | ||
- [k8s_oidc_github_pages_github_known_hosts_path](#k8s_oidc_github_pages_github_known_hosts_path) | ||
- [k8s_oidc_github_pages_gpg_private_key_path](#k8s_oidc_github_pages_gpg_private_key_path) | ||
- [k8s_oidc_github_pages_random_sleep_enabled](#k8s_oidc_github_pages_random_sleep_enabled) | ||
- [k8s_oidc_github_pages_repository_name](#k8s_oidc_github_pages_repository_name) | ||
- [k8s_oidc_github_pages_repository_owner](#k8s_oidc_github_pages_repository_owner) | ||
- [k8s_oidc_github_pages_repository_ssh_url](#k8s_oidc_github_pages_repository_ssh_url) | ||
- [k8s_oidc_github_pages_sign_gpg_private_key](#k8s_oidc_github_pages_sign_gpg_private_key) | ||
- [k8s_oidc_github_pages_ssh_config_host](#k8s_oidc_github_pages_ssh_config_host) | ||
- [k8s_oidc_github_pages_ssh_config_path](#k8s_oidc_github_pages_ssh_config_path) | ||
- [k8s_oidc_github_pages_ssh_private_key_path](#k8s_oidc_github_pages_ssh_private_key_path) | ||
- [k8s_oidc_github_pages_timer_calendar](#k8s_oidc_github_pages_timer_calendar) | ||
- [Dependencies](#dependencies) | ||
- [License](#license) | ||
- [Author](#author) | ||
|
||
--- | ||
|
||
## Requirements | ||
|
||
- Minimum Ansible version: `2.17` | ||
|
||
## Default Variables | ||
|
||
### k8s_oidc_github_pages_commit_email | ||
|
||
#### Default value | ||
|
||
```YAML | ||
k8s_oidc_github_pages_commit_email: k8s-oidc-github-pages[bot]@users.noreply.github.com | ||
``` | ||
### k8s_oidc_github_pages_commit_name | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_commit_name: K8s OIDC GitHub Pages | ||
``` | ||
### k8s_oidc_github_pages_debug | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_debug: true | ||
``` | ||
### k8s_oidc_github_pages_environments | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_environments: | | ||
KUBECONFIG=/etc/rancher/k3s/k3s.yaml | ||
``` | ||
### k8s_oidc_github_pages_github_deploy_key | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_github_deploy_key: | ||
``` | ||
### k8s_oidc_github_pages_github_known_hosts_path | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_github_known_hosts_path: .ssh/known_hosts | ||
``` | ||
### k8s_oidc_github_pages_gpg_private_key_path | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_gpg_private_key_path: .gnupg/github-signing-key.asc | ||
``` | ||
### k8s_oidc_github_pages_random_sleep_enabled | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_random_sleep_enabled: false | ||
``` | ||
### k8s_oidc_github_pages_repository_name | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_repository_name: | ||
``` | ||
### k8s_oidc_github_pages_repository_owner | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_repository_owner: | ||
``` | ||
### k8s_oidc_github_pages_repository_ssh_url | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_repository_ssh_url: git@github.com:{{ k8s_oidc_github_pages_repository_owner | ||
}}/{{ k8s_oidc_github_pages_repository_name }}.git | ||
``` | ||
### k8s_oidc_github_pages_sign_gpg_private_key | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_sign_gpg_private_key: | ||
``` | ||
### k8s_oidc_github_pages_ssh_config_host | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_ssh_config_host: k8s-oidc-github-pages | ||
``` | ||
### k8s_oidc_github_pages_ssh_config_path | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_ssh_config_path: .ssh/config | ||
``` | ||
### k8s_oidc_github_pages_ssh_private_key_path | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_ssh_private_key_path: .ssh/github-deploy-key | ||
``` | ||
### k8s_oidc_github_pages_timer_calendar | ||
#### Default value | ||
```YAML | ||
k8s_oidc_github_pages_timer_calendar: '*:0/5' | ||
``` | ||
## Dependencies | ||
None. | ||
## License | ||
Apache-2.0 | ||
## Author | ||
Meysam Azad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
k8s_oidc_github_pages_commit_email: k8s-oidc-github-pages[bot]@users.noreply.github.com | ||
k8s_oidc_github_pages_commit_name: K8s OIDC GitHub Pages | ||
k8s_oidc_github_pages_debug: true | ||
k8s_oidc_github_pages_environments: | | ||
KUBECONFIG=/etc/rancher/k3s/k3s.yaml | ||
k8s_oidc_github_pages_github_deploy_key: null | ||
k8s_oidc_github_pages_github_known_hosts_path: .ssh/known_hosts | ||
k8s_oidc_github_pages_gpg_private_key_path: .gnupg/github-signing-key.asc | ||
k8s_oidc_github_pages_random_sleep_enabled: false | ||
k8s_oidc_github_pages_repository_name: null | ||
k8s_oidc_github_pages_repository_owner: null | ||
k8s_oidc_github_pages_repository_ssh_url: git@github.com:{{ k8s_oidc_github_pages_repository_owner }}/{{ k8s_oidc_github_pages_repository_name }}.git | ||
k8s_oidc_github_pages_sign_gpg_private_key: null | ||
k8s_oidc_github_pages_ssh_config_host: k8s-oidc-github-pages | ||
k8s_oidc_github_pages_ssh_config_path: .ssh/config | ||
k8s_oidc_github_pages_ssh_private_key_path: .ssh/github-deploy-key | ||
k8s_oidc_github_pages_timer_calendar: "*:0/5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl | ||
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg= | ||
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
galaxy_info: | ||
author: Meysam Azad | ||
description: | | ||
Fetch Kubernetes OpenID Configuration and JWKs keys and push and deploy them to GitHub Pages as static files. | ||
Grab the OIDC configuration file from K8s API server and push it into a | ||
GitHub repository with Pages enabled. | ||
This will ultimately result in serving static files from a public URL with TLS | ||
enabled. | ||
As a result, the administrator can set up trust relationship with other | ||
service providers, such as AWS, to allow pods inside the Kubernetes cluster | ||
access to third-party cloud services. | ||
Although this is tailored for K3d Kubernetes cluster, there is nothing stopping | ||
it from being used on other Kubernetes clusters. | ||
company: Self employed | ||
|
||
issue_tracker_url: http://github.com/meysam81/ansible-collections/issues | ||
license: Apache-2.0 | ||
|
||
min_ansible_version: "2.17" | ||
|
||
galaxy_tags: | ||
- kubernetes | ||
- oidc | ||
- github | ||
- pages | ||
- openid | ||
- jwks | ||
- security | ||
- authentication | ||
- authorization | ||
- identity | ||
- federation | ||
- sso | ||
- saml | ||
- oauth | ||
- jwt | ||
- jwe | ||
- jws | ||
- jwk | ||
|
||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- name: Setup Debian | ||
ansible.builtin.include_tasks: setup-Debian.yml | ||
when: ansible_os_family == 'Debian' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
- name: Assert required vars are defined | ||
ansible.builtin.assert: | ||
that: | ||
- k8s_oidc_github_pages_repository_name | default('', true) | length > 0 | ||
- k8s_oidc_github_pages_repository_owner | default('', true) | length > 0 | ||
- k8s_oidc_github_pages_github_deploy_key | default('', true) | length > 0 | ||
- name: Ensure /root/.ssh exists | ||
ansible.builtin.file: | ||
group: root | ||
mode: "0700" | ||
owner: root | ||
path: /root/.ssh | ||
state: directory | ||
- name: Ensure /root/.gnupg exists | ||
ansible.builtin.file: | ||
group: root | ||
mode: "0700" | ||
owner: root | ||
path: /root/.gnupg | ||
state: directory | ||
- name: Copy GitHub Deploy key | ||
ansible.builtin.copy: | ||
content: "{{ k8s_oidc_github_pages_github_deploy_key }}" | ||
dest: /root/{{ k8s_oidc_github_pages_ssh_private_key_path }} | ||
group: root | ||
mode: "0600" | ||
owner: root | ||
no_log: true | ||
- name: Add GitHub Known hosts entry | ||
ansible.builtin.blockinfile: | ||
path: "/root/{{ k8s_oidc_github_pages_github_known_hosts_path }}" | ||
create: true | ||
mode: "0644" | ||
block: "{{ lookup('file', 'github-known-hosts') }}" | ||
marker: "# {mark} GITHUB KNOWN HOSTS" | ||
state: present | ||
- name: Create SSH config block for GitHub Pages | ||
ansible.builtin.blockinfile: | ||
path: "/root/{{ k8s_oidc_github_pages_ssh_config_path }}" | ||
create: true | ||
mode: "0600" | ||
block: "{{ lookup('template', 'ssh-config.j2') }}" | ||
marker: "# {mark} K8S OIDC GITHUB PAGES SSH CONFIG" | ||
state: present | ||
- name: Copy Sign GPG private key | ||
ansible.builtin.copy: | ||
content: "{{ k8s_oidc_github_pages_sign_gpg_private_key }}" | ||
dest: /root/{{ k8s_oidc_github_pages_gpg_private_key_path }} | ||
group: root | ||
mode: "0600" | ||
owner: root | ||
no_log: true | ||
when: k8s_oidc_github_pages_sign_gpg_private_key | default('', true) | length > 0 | ||
- name: Copy the K8s OIDC GitHub Pages shell script | ||
ansible.builtin.template: | ||
src: k8s-oidc-github-pages.sh.j2 | ||
dest: /usr/local/bin/k8s-oidc-github-pages | ||
owner: root | ||
group: root | ||
mode: "0755" | ||
- name: Copy environment variable file | ||
ansible.builtin.copy: | ||
content: "{{ k8s_oidc_github_pages_environments }}" | ||
dest: /etc/default/k8s-oidc-github-pages | ||
owner: root | ||
group: root | ||
mode: "0640" | ||
- name: Copy k8s oidc github pages service file | ||
ansible.builtin.template: | ||
src: k8s-oidc-github-pages.service.j2 | ||
dest: /etc/systemd/system/k8s-oidc-github-pages.service | ||
owner: root | ||
group: root | ||
mode: "0644" | ||
- name: Copy k8s oidc github pages timer file | ||
ansible.builtin.template: | ||
src: k8s-oidc-github-pages.timer.j2 | ||
dest: /etc/systemd/system/k8s-oidc-github-pages.timer | ||
owner: root | ||
group: root | ||
mode: "0644" | ||
- name: Start the k8s oidc github pages systemd timer | ||
ansible.builtin.systemd: | ||
name: k8s-oidc-github-pages.timer | ||
enabled: true | ||
daemon_reload: true | ||
state: started |
Oops, something went wrong.