Skip to content
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
79 changes: 79 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Create and publish Docker images

on:
push:
branches: ["main", "dev"]
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]

# Defines custom environment variables for the workflow
env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}
CURRENT_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
build-and-push-images:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
docker_config:
- dockerfile: docker/Dockerfile.osken
image_suffix: osken
platform:
- linux/amd64

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Tag or Branch Type
id: tag_or_branch_check
run: |
BRANCH_NAME=$(echo "$CURRENT_BRANCH_NAME" | sed 's|/|_|g')
if [[ ${BRANCH_NAME} == main ]]; then
echo "TAG_NAME=latest" >> $GITHUB_ENV
elif [[ ${BRANCH_NAME} == dev ]]; then
echo "TAG_NAME=canary" >> $GITHUB_ENV
else
echo "TAG_NAME=canary-${BRANCH_NAME}" >> $GITHUB_ENV
fi

- name: Set image name with suffix
id: image_name
run: |
IMAGE_NAME="${REPO_NAME}-${{ matrix.docker_config.image_suffix }}"
echo "FULL_IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "Image name set to: ${IMAGE_NAME}"

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.FULL_IMAGE_NAME }}
tags: ${{ env.TAG_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
with:
context: docker/.
file: ${{ matrix.docker_config.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| containerlab | https://containerlab.dev/ | 为docker搭建网络拓扑的工具(yaml配置文件) |
| containernet | https://containernet.github.io/ | 支持sdn/docker的网络拓扑搭建工具(python代码实现) |
| ryu | https://ryu-sdn.org/ | python实现的sdn控制器,支持bgp |
| os-ken | https://github.com/openstack/os-ken/ | python实现的sdn控制器,支持bgp, 为ryu的后续维护版本 |

<table style="text-align: center;">
<tr>
Expand Down Expand Up @@ -65,6 +66,21 @@
</tr>
</table>

## os-ken 容器

### 1. 拉取镜像

```bash
docker pull ghcr.io/code-with-bgp-xd/infrastructure-osken:latest
```

### 2. 与containerlab配合使用

在本机安装好containerlab的情况下

参考 https://github.com/code-with-bgp-XD/frr-utilities/blob/main/ryu-bgpspeaker/os-ken/p2p/osken.clab.yaml


## sdn+ovs

### 1. clone 本仓库
Expand Down
41 changes: 41 additions & 0 deletions docker/Dockerfile.osken
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM python:3.11-slim as prepare

Check warning on line 1 in docker/Dockerfile.osken

View workflow job for this annotation

GitHub Actions / build-and-push-images (docker/Dockerfile.osken, osken, linux/amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 1 in docker/Dockerfile.osken

View workflow job for this annotation

GitHub Actions / build-and-push-images (docker/Dockerfile.osken, osken, linux/amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

RUN apt update && \
apt install -y --no-install-recommends \
git

WORKDIR /app

RUN git clone https://github.com/openstack/os-ken.git && \
cd os-ken && \
git checkout 3.0.1

FROM python:3.11-slim as runner

Check warning on line 13 in docker/Dockerfile.osken

View workflow job for this annotation

GitHub Actions / build-and-push-images (docker/Dockerfile.osken, osken, linux/amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 13 in docker/Dockerfile.osken

View workflow job for this annotation

GitHub Actions / build-and-push-images (docker/Dockerfile.osken, osken, linux/amd64)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /app

COPY --from=prepare /app/os-ken /app/os-ken

ADD ./osken-bgp.patch .

# 安装构建依赖
RUN apt update && \
apt install -y --no-install-recommends \
git patch && \
pip install --upgrade pip && \
pip install pbr paramiko && \
cd /app/os-ken && \
patch -p1 < /app/osken-bgp.patch && \
pip install .

# 清理
RUN rm -rf /app/os-ken && \
apt remove -y git patch && \
apt autoremove -y && \
apt clean

RUN apt update \
&& apt install -y --no-install-recommends \
iproute2 iputils-ping openssh-client

CMD ["bash"]
19 changes: 19 additions & 0 deletions docker/osken-bgp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/os_ken/services/protocols/bgp/operator/ssh.py
+++ b/os_ken/services/protocols/bgp/operator/ssh.py
@@ -25,7 +25,6 @@

import paramiko

-from os_ken import version
from os_ken.lib import hub
from os_ken.services.protocols.bgp.base import Activity
from os_ken.services.protocols.bgp.operator.command import Command
@@ -59,7 +58,7 @@
class SshServer(paramiko.ServerInterface):
TERM = "ansi"
PROMPT = "bgpd> "
- WELCOME = "\n\rHello, this is OSKen BGP speaker (version %s).\n\r" % version
+ WELCOME = "\n\rHello, this is OSKen BGP speaker.\n\r"

class HelpCmd(Command):
help_msg = 'show this help'