Skip to content

Commit

Permalink
feature: add controller docker CI (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptyin committed Jan 17, 2024
1 parent 725cba8 commit 569aca8
Show file tree
Hide file tree
Showing 27 changed files with 186 additions and 116 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker Build And Go Test
run: make docker-build
32 changes: 32 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish Docker

on:
push:
branches: [ master, "*.*.*" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Build and Push
run: |
if [ "${{ github.ref_name }}" == "master" ]; then
make docker-build docker-push
else
IMG=apache/seata-controller:${{ github.ref_name }} make docker-build docker-push
fi
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# This variable is used to construct full image tags for bundle and catalog images.
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# seata.io/seata-k8s-bundle:$VERSION and seata.io/seata-k8s-catalog:$VERSION.
IMAGE_TAG_BASE ?= seata.io/seata-k8s
# seata.apache.org/seata-k8s-bundle:$VERSION and seata.apache.org/seata-k8s-catalog:$VERSION.
IMAGE_TAG_BASE ?= seata.apache.org/seata-k8s

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
Expand All @@ -51,7 +51,7 @@ endif
OPERATOR_SDK_VERSION ?= v1.32.0

# Image URL to use all building/pushing image targets
IMG ?= seata-controller:latest
IMG ?= docker.io/apache/seata-controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.0

Expand Down
8 changes: 4 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: seata.io
domain: seata.apache.org
layout:
- go.kubebuilder.io/v3
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
projectName: seata-k8s
repo: github.com/seata/seata-k8s
repo: github.com/apache/incubator-seata-k8s
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: seata.io
domain: seata.apache.org
group: operator
kind: SeataServer
path: github.com/seata/seata-k8s/api/v1alpha1
path: github.com/apache/seata-k8s/api/v1alpha1
version: v1alpha1
version: "3"
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ Associated Projects:

### Usage

We haven't officially released the Controller image yet. To experience deploying Seata Server using the Operator method, follow these steps:
To experience deploying Seata Server using the Operator method, follow these steps:

1. Clone this repository:

```shell
git clone https://github.com/apache/incubator-seata-k8s.git
```

2. Publish the controller image to a private registry:
2. (Optional) Build and publish the controller image to a private registry:

> This step can be skipped, the operator use apache/seata-controller:latest as controller image by default.
```shell
IMG=${IMAGE-TO-PUSH} make docker-build docker-push
Expand All @@ -30,7 +32,7 @@ We haven't officially released the Controller image yet. To experience deploying

```shell
eval $(minikube docker-env)
make docker-build
IMG=${IMAGE-TO-PUSH} make docker-build
```

3. Deploy Controller, CRD, RBAC, and other resources to the Kubernetes cluster:
Expand All @@ -43,7 +45,7 @@ We haven't officially released the Controller image yet. To experience deploying
4. You can now deploy your CR to the cluster. An example can be found here [seata-server-cluster.yaml](deploy/seata-server-cluster.yaml):

```yaml
apiVersion: operator.seata.io/v1alpha1
apiVersion: operator.seata.apache.org/v1alpha1
kind: SeataServer
metadata:
name: seata-server
Expand All @@ -62,7 +64,7 @@ We haven't officially released the Controller image yet. To experience deploying

### Reference

For CRD details, you can visit [operator.seata.io_seataservers.yaml](config/crd/bases/operator.seata.io_seataservers.yaml). Here are some important configurations:
For CRD details, you can visit [operator.seata.apache.org_seataservers.yaml](config/crd/bases/operator.seata.apache.org_seataservers.yaml). Here are some important configurations:

1. `serviceName`: Used to define the name of the Headless Service deployed by the controller. This will affect how you access the server cluster. In the example above, you can access the Seata Server cluster through `seata-server-0.seata-server-cluster.default.svc`.

Expand All @@ -79,7 +81,7 @@ For CRD details, you can visit [operator.seata.io_seataservers.yaml](config/crd/
7. `env`: Environment variables passed to the container. You can use this field to define Seata Server configuration. For example:

```yaml
apiVersion: operator.seata.io/v1alpha1
apiVersion: operator.seata.apache.org/v1alpha1
kind: SeataServer
metadata:
name: seata-server
Expand All @@ -92,7 +94,7 @@ For CRD details, you can visit [operator.seata.io_seataservers.yaml](config/crd/
storage: 5Gi
env:
console.user.username: seata
console.user.username: seata
console.user.password: seata
```

## Method 2: Example without Using Operator
Expand Down
20 changes: 11 additions & 9 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ https://github.com/seata/seata-docker

### Usage

我们暂未没发布官方的 Controller 镜像,想要体验 Operator 方式部署 Seata Server 可以参照以下方式进行:
想要体验 Operator 方式部署 Seata Server 可以参照以下方式进行:

1. 克隆本仓库

```shell
git clone https://github.com/apache/incubator-seata-k8s.git
```

2. 发布 controller 镜像到私有 Registry
2. (可选) 发布 controller 镜像到私有 Registry

> 这一步可以跳过,本 Operator 默认使用 `apache/seata-controller:latest` 作为 controller 镜像
```shell
IMG=${IMAGE-TO-PUSH} make docker-build docker-push
Expand All @@ -34,7 +36,7 @@ https://github.com/seata/seata-docker

```shell
eval $(minikube docker-env)
make docker-build
IMG=${IMAGE-TO-PUSH} make docker-build
```

3. 部署 Controller, CRD, RBAC 等资源到 Kubernetes 集群
Expand All @@ -47,7 +49,7 @@ https://github.com/seata/seata-docker
4. 此时即可发布你的 CR 到集群当中了,示例可以在这里找到 [seata-server-cluster.yaml](deploy/seata-server-cluster.yaml)

```yaml
apiVersion: operator.seata.io/v1alpha1
apiVersion: operator.seata.apache.org/v1alpha1
kind: SeataServer
metadata:
name: seata-server
Expand All @@ -67,7 +69,7 @@ https://github.com/seata/seata-docker

### Reference

关于 CRD 可以访问 [operator.seata.io_seataservers.yaml](config/crd/bases/operator.seata.io_seataservers.yaml) 以查看详细定义,这里列举出一些重要的配置并进行解读。
关于 CRD 可以访问 [operator.seata.apache.org_seataservers.yaml](config/crd/bases/operator.seata.apache.org_seataservers.yaml) 以查看详细定义,这里列举出一些重要的配置并进行解读。

1. `serviceName`: 用于定义 controller 部署的 Headless Service 的名称,这会影响你访问 server 集群的方式,比如在之前的示例中,你可以通过 seata-server-0.seata-server-cluster.default.svc 进行访问。

Expand All @@ -84,7 +86,7 @@ https://github.com/seata/seata-docker
7. `env`: 传递给容器的环境变量,可以通过此字段去定义 Seata Server 的配置,比如:

```yaml
apiVersion: operator.seata.io/v1alpha1
apiVersion: operator.seata.apache.org/v1alpha1
kind: SeataServer
metadata:
name: seata-server
Expand All @@ -95,9 +97,9 @@ https://github.com/seata/seata-docker
resources:
requests:
storage: 5Gi
env:
console.user.username: seata
console.user.username: seata
env:
console.user.username: seata
console.user.password: seata
```


Expand Down
15 changes: 8 additions & 7 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
Copyright 1999-2019 Seata.io Group.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
17 changes: 9 additions & 8 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
Copyright 1999-2019 Seata.io Group.
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -16,7 +17,7 @@ limitations under the License.

// Package v1alpha1 contains API Schema definitions for the seata v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=operator.seata.io
// +groupName=operator.seata.apache.org
package v1alpha1

import (
Expand All @@ -26,7 +27,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "operator.seata.io", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "operator.seata.apache.org", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
15 changes: 8 additions & 7 deletions api/v1alpha1/seataserver_types.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
Copyright 1999-2019 Seata.io Group.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
15 changes: 8 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: seataservers.operator.seata.io
name: seataservers.operator.seata.apache.org
spec:
group: operator.seata.io
group: operator.seata.apache.org
names:
kind: SeataServer
listKind: SeataServerList
Expand Down
2 changes: 1 addition & 1 deletion config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/operator.seata.io_seataservers.yaml
- bases/operator.seata.apache.org_seataservers.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/cainjection_in_seataservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: seataservers.operator.seata.io
name: seataservers.operator.seata.apache.org
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_seataservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: seataservers.operator.seata.io
name: seataservers.operator.seata.apache.org
spec:
conversion:
strategy: Webhook
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: seata-controller
newName: docker.io/apache/seata-controller
newTag: latest

0 comments on commit 569aca8

Please sign in to comment.