Skip to content

Commit

Permalink
Resolved merge conflict by incorporating both suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
6454s committed Jan 26, 2023
2 parents ef0e4c6 + 5410cc7 commit 2bcfea7
Show file tree
Hide file tree
Showing 24 changed files with 276 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
check-super-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.3.0
- name: Check super-linter
uses: github/super-linter@v4.9.7
uses: github/super-linter@v4.10.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: .github/linters
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on-demand_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: Check scripts format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.3.0
- name: Run the sh-checker
uses: luizm/[email protected]
env:
Expand All @@ -44,7 +44,7 @@ jobs:
env:
DEBUG: true
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.3.0
- name: Install dependencies and configures kind clusters
working-directory: ./scripts
run: ./install.sh
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
check-dockerfile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v3.3.0
- name: update Dockerfile
uses: ludeeus/[email protected]
with:
Expand Down
18 changes: 10 additions & 8 deletions ansible_kind/scripts/multiclusterkind/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ function _create_gh_secret {

if [ -f "$nephio_gh_filename" ]; then
for kubeconfig in ~/.kube/*.config; do
/home/ubuntu/.local/bin/kubectl create secret generic -n default \
github-personal-access-token \
--from-literal username=nephio-test \
--from-file password="${nephio_gh_filename}" \
--type kubernetes.io/basic-auth \
--kubeconfig "$kubeconfig"
if [ ! kubectl get secrets github-personal-access-token -n default --kubeconfig "$kubeconfig" ]; then
/home/ubuntu/.local/bin/kubectl create secret generic -n default \
github-personal-access-token \
--from-literal username=nephio-test \
--from-file password="${nephio_gh_filename}" \
--type kubernetes.io/basic-auth \
--kubeconfig "$kubeconfig"
fi
done
fi
rm -rf "${nephio_gh_filename}"
Expand Down Expand Up @@ -93,8 +95,8 @@ kpt live apply "$participant_path" --reconcile-timeout=15m --kubeconfig ~/.kube/

# Install ConfigSync on each workload cluster
for kubeconfig in ~/.kube/*.config; do
if [[ "$kubeconfig" =~ nephio.config$ ]]; then
continue
if [[ $kubeconfig =~ nephio.config$ ]]; then
continue
fi
_install_configsync "$kubeconfig"
done
Expand Down
2 changes: 2 additions & 0 deletions nephio-ansible-install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ all:
github_organization: <optional, if a GitHub organization is used this should be filled out with the GitHub organization>
gitea_username: <gitea username>
gitea_password: <gitea password>
dockerhub_username: <dockerhub username>
dockerhub_token: <dockerhub token or password>
proxy:
http_proxy:
https_proxy:
Expand Down
4 changes: 3 additions & 1 deletion nephio-ansible-install/playbooks/create-gitea.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
https_proxy: "{{proxy.https_proxy}}"
no_proxy: "{{proxy.no_proxy}}"
roles:
- {role: gitea/create, tags: gitea}
- role: dockerhub/login
- { role: gitea/create, tags: gitea}
- role: dockerhub/logout
28 changes: 19 additions & 9 deletions nephio-ansible-install/playbooks/install-prereq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
http_proxy: "{{proxy.http_proxy}}"
https_proxy: "{{proxy.https_proxy}}"
no_proxy: "{{proxy.no_proxy}}"

pre_tasks:
- name: install packages
become: true
ansible.builtin.package:
name:
- git
state: present

roles:
- {role: docker, tags: docker}
- {role: kubectl, tags: kubectl}
- {role: kind, tags: kind}
- {role: kpt, tags: kpt}
- {role: cni, tags: cni}
- {role: bash, tags: bash}
- {role: tree, tags: tree}
- {role: nephio/install, tags: nephio}
- {role: clab, tags: clab}

- { role: docker, tags: docker}
- { role: kubectl, tags: kubectl}
- { role: kind, tags: kind}
- { role: kpt, tags: kpt}
- { role: cni, tags: cni }
- { role: bash, tags: bash }
- { role: tree, tags: tree}
- { role: nephio/install, tags: nephio}
- { role: clab, tags: clab}
2 changes: 2 additions & 0 deletions nephio-ansible-install/roles/clab/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## © 2022 Nephio Authors
## Licensed under the Apache License 2.0
## SPDX-License-Identifier: Apache-2.0

---
- name: installing clab
become: true
shell: bash -c "$(wget -qO - https://get.containerlab.dev)"
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
when: item.key == "mgmt"

- name: Deploy cluster {{ item.key }}
shell: "kind create cluster --name {{ item.key }} --kubeconfig ~/.kube/{{ item.key }}-config --config /tmp/{{ item.key }}-cluster-config.yaml"
shell: "kind create cluster --name {{ item.key }} --kubeconfig ~/.kube/{{ item.key }}-config --config {{ tmp_directory }}/{{ item.key }}-cluster-config.yaml"
register: result
failed_when:
- result.rc > 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ networking:
nodes:
- role: control-plane
extraMounts:
- hostPath: /tmp/cni
- hostPath: "{{ tmp_directory }}/cni"
containerPath: /opt/cni/bin
18 changes: 18 additions & 0 deletions nephio-ansible-install/roles/docker/tasks/docker-Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## © 2023 Nephio Authors
## Licensed under the Apache License 2.0
## SPDX-License-Identifier: Apache-2.0

---
- name: ensure repository key is installed
become: true
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present

- name: ensure docker registry is available
become: true
apt_repository: repo='deb https://download.docker.com/linux/ubuntu bionic stable' state=present

- name: ensure docker and dependencies are installed
become: true
apt: name=docker-ce update_cache=yes
37 changes: 37 additions & 0 deletions nephio-ansible-install/roles/docker/tasks/docker-RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## © 2023 Nephio Authors
## Licensed under the Apache License 2.0
## SPDX-License-Identifier: Apache-2.0

---
- name: set mydistribution
ansible.builtin.set_fact:
mydistribution: "{{ 'rhel' if (ansible_distribution == 'RedHat') else (ansible_distribution | lower) }}"

- name: Add signing key
ansible.builtin.rpm_key:
key: "https://download.docker.com/linux/{{ mydistribution }}/gpg"
state: present

- name: Add repository into repo.d list
ansible.builtin.yum_repository:
name: docker
description: docker repository
baseurl: "https://download.docker.com/linux/{{ mydistribution }}/$releasever/$basearch/stable"
enabled: true
gpgcheck: true
gpgkey: "https://download.docker.com/linux/{{ mydistribution }}/gpg"

- name: Install Docker
ansible.builtin.yum:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: latest
update_cache: true

- name: Start Docker
ansible.builtin.service:
name: "docker"
enabled: true
state: started
27 changes: 13 additions & 14 deletions nephio-ansible-install/roles/docker/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
## © 2022 Nephio Authors
## © 2023 Nephio Authors
## Licensed under the Apache License 2.0
## SPDX-License-Identifier: Apache-2.0

---
- name: ensure repository key is installed
become: true
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present

- name: ensure docker registry is available
become: true
apt_repository: repo='deb https://download.docker.com/linux/ubuntu bionic stable' state=present
- name: check if docker already installed
ansible.builtin.shell: service docker status
register: docker_status

- name: ensure docker and dependencies are installed
become: true
apt: name=docker-ce update_cache=yes
- include_tasks: "docker-{{ ansible_os_family }}.yaml"
args:
apply:
become: true
when: docker_status.rc != 0

- name: Add user to docker group
ansible.builtin.user:
name: "{{ cloud_user }}"
group: docker
become: true
shell: usermod -aG docker {{ cloud_user }}
when: docker_status.rc != 0

- name: Reset connection so docker group is picked up.
meta: reset_connection
Expand Down
9 changes: 9 additions & 0 deletions nephio-ansible-install/roles/dockerhub/login/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## © 2023 Nephio Authors
## Licensed under the Apache License 2.0
## SPDX-License-Identifier: Apache-2.0
---

- name: login into dockerhub
docker_login:
username: "{{ dockerhub_username }}"
password: "{{ dockerhub_token }}"
8 changes: 8 additions & 0 deletions nephio-ansible-install/roles/dockerhub/logout/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## © 2023 Nephio Authors
## Licensed under the Apache License 2.0
## SPDX-License-Identifier: Apache-2.0
---

- name: logout of Dockerhub
docker_login:
state: absent
3 changes: 3 additions & 0 deletions nephio-ansible-install/roles/nephio/config/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
- name: configure ipam
shell: kubectl --kubeconfig ~/.kube/mgmt-config apply -f {{ tmp_directory }}/ipam.yaml

- name: deploy mgmt cluster manifests
include_tasks: manifest_mgmt_files.yaml

- name: deploy edge cluster manifests
include_tasks: manifest_files.yaml
with_dict: "{{ clusters }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## © 2022 Nephio Authors
## Licensed under the Apache License 2.0
## SPDX-License-Identifier: Apache-2.0

---
- name: github repo
set_fact:
github_repo: "{{ 'https://github.com/{{ github_organization}}/nephio-catalog.git' if github_organization is defined else 'https://github.com/{{ github_username}}/nephio-catalog.git' }}"
when:
- github_username is defined

- name: copy mgmt github repo
template:
src: "{{ role_path }}/templates/github-mgmt-repo.j2"
dest: "{{ tmp_directory }}/github-mgmt-repo-catalog.yaml"
mode: 0644
when:
- github_username is defined

- name: configure mgmt github repo
shell: kubectl --kubeconfig ~/.kube/mgmt-config apply -f {{ tmp_directory }}/github-mgmt-repo-catalog.yaml
when:
- github_username is defined

- name: copy edge gitea repo
template:
src: "{{ role_path }}/templates/gitea-mgmt-repo.j2"
dest: "{{ tmp_directory }}/gitea-mgmt-repo-catalog.yaml"
mode: 0644
when:
- gitea_username is defined

- name: configure edge gitea repo
shell: kubectl --kubeconfig ~/.kube/mgmt-config apply -f {{ tmp_directory }}/gitea-mgmt-repo-catalog.yaml
when:
- gitea_username is defined
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: config.porch.kpt.dev/v1alpha1
kind: Repository
metadata:
name: catalog
namespace: default
labels:
kpt.dev/repository-content: organizational-blueprints
spec:
content: Package
deployment: false
git:
branch: main
createBranch: true
directory: /
repo: http://gitea:3000/nephio/nephio-catalog.git
secretRef:
name: gitea-access-token
type: git
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: config.porch.kpt.dev/v1alpha1
kind: Repository
metadata:
name: catalog
namespace: default
labels:
kpt.dev/repository-content: organizational-blueprints
spec:
content: Package
deployment: false
git:
branch: main
directory: /
repo: {{github_repo}}
secretRef:
name: github-personal-access-token
type: git
20 changes: 20 additions & 0 deletions nephio-ansible-install/roles/repo-gitea/create/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
until: _result.status == 200
retries: 12 # 12 * 5 seconds = 1min (60/5)
delay: 5 # Every 5 seconds

- name: Create repos
ansible.builtin.uri:
url: http://localhost:3000/api/v1/user/repos
Expand All @@ -32,6 +33,25 @@
with_dict: "{{ clusters }}"
when:
- gitea_username is defined
- item.key != "mgmt"

- name: Create repos
ansible.builtin.uri:
url: http://localhost:3000/api/v1/user/repos
headers:
Authorization: token {{ gitea_token['content'] | b64decode }}
Content-Type: application/json
accept: application/json
method: POST
body: {'auto_init': true, 'name': "nephio-catalog"}
status_code: 201
body_format: json
register: result
with_dict: "{{ clusters }}"
when:
- gitea_username is defined
- item.key == "mgmt"

- name: Print return information from the previous task
ansible.builtin.debug:
var: result
Expand Down
Loading

0 comments on commit 2bcfea7

Please sign in to comment.