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

新增自定义REPO支持 #481

Merged
merged 6 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion ansible/filter_plugins/to_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from kubez_ansible.to_socket import to_socket
from kubez_ansible.get_runtime_type import get_runtime_type

Expand All @@ -20,11 +22,26 @@
'''


def find_custom_repo(ctx, *args, **kwargs):
dest = kwargs.get('dest')
repo_dir = kwargs.get('repo_dir')

parts = dest.split('/')
repo_name = parts[len(parts) - 1]

custom_repo = os.path.join(repo_dir, repo_name)
if os.path.exists(custom_repo):
return custom_repo
else:
return ctx


class FilterModule(object):
'''Kubez-ansible custom jinja2 filters '''

def filters(self):
return {
'to_socket': to_socket,
'get_runtime_type': get_runtime_type
'get_runtime_type': get_runtime_type,
'find_custom_repo': find_custom_repo
}
3 changes: 3 additions & 0 deletions ansible/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ image_repository: "registry.cn-hangzhou.aliyuncs.com/google_containers"
# 自定义镜像仓库
app_image_repository: "harbor.cloud.pixiuio.com/pixiuio"

# 自定义 REPO 仓库
repo_dir: "/etc/kubez/repo"

# pixiu helm chart 仓库地址
default_repo_name: "pixiuio"
default_repo_url: "https://harbor.cloud.pixiuio.com/chartrepo/pixiuio"
Expand Down
12 changes: 2 additions & 10 deletions ansible/roles/baremetal/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
- {name: "nfs-kernel-server", group: "storage", os: "Ubuntu", use: "apt"}
- {name: "rpcbind", group: "storage", os: "Debian", use: "apt"}
- {name: "nfs-kernel-server", group: "storage", os: "Debian", use: "apt"}
- {name: "rpcbind", group: "storage", os: "CentOS", use: "yum"}
- {name: "nfs-utils", group: "storage", os: "CentOS", use: "yum"}
- {name: "rpcbind", group: "storage", os: "Rocky", use: "dnf"}
- {name: "nfs-utils", group: "storage", os: "Rocky", use: "dnf"}
- {name: "rpcbind", group: "storage", os: "openEuler", use: "dnf"}
Expand All @@ -34,11 +32,9 @@
block:
- name: Copy container runtime repos for kubernetes nodes
template:
src: "{{ item.src }}"
src: "{{ item.src | find_custom_repo(dest=item.dest, repo_dir=repo_dir) }}"
dest: "{{ item.dest }}"
loop:
- {"src": docker-ce.repo.j2, "dest": /etc/yum.repos.d/docker-ce.repo, os: "CentOS"}
- {"src": kubernetes.repo.j2, "dest": /etc/yum.repos.d/kubernetes.repo, os: "CentOS"}
- {"src": sources.list.j2, "dest": /etc/apt/sources.list, os: "Ubuntu"}
- {"src": sources.list.debian.j2, "dest": /etc/apt/sources.list, os: "Debian"}
- {"src": docker-ce.repo.j2, "dest": /etc/yum.repos.d/docker-ce.repo, os: "Rocky"}
Expand All @@ -48,13 +44,12 @@
when:
- ansible_distribution == item.os

- name: Add docker, kubernetes and helm gpgs
- name: Add docker, and kubernetes gpgs
apt_key:
url: "{{ item }}"
loop:
- https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg
- https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg
# - helm.gpg
when:
- ansible_distribution == 'Ubuntu' or
ansible_distribution == 'Debian'
Expand All @@ -78,9 +73,6 @@
- {name: "kubelet={{ kube_release_ubuntu }}", os: "Debian", use: "apt"}
- {name: "kubectl={{ kube_release_ubuntu }}", os: "Debian", use: "apt"}
- {name: "kubeadm={{ kube_release_ubuntu }}", os: "Debian", use: "apt"}
- {name: "kubelet-{{ kube_release }}", os: "CentOS", use: "yum"}
- {name: "kubectl-{{ kube_release }}", os: "CentOS", use: "yum"}
- {name: "kubeadm-{{ kube_release }}", os: "CentOS", use: "yum"}
- {name: "kubelet-{{ kube_release }}", os: "Rocky", use: "dnf"}
- {name: "kubectl-{{ kube_release }}", os: "Rocky", use: "dnf"}
- {name: "kubeadm-{{ kube_release }}", os: "Rocky", use: "dnf"}
Expand Down
3 changes: 3 additions & 0 deletions etc/kubez/globals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ image_repository: "registry.cn-hangzhou.aliyuncs.com/google_containers"
# 自定义镜像仓库
app_image_repository: "harbor.cloud.pixiuio.com/pixiuio"

# 自定义 REPO 仓库
repo_dir: "/etc/kubez/repo"

###############
# Host Options
###############
Expand Down
Loading