Skip to content

Commit

Permalink
feature(main): change gomod sealyun to labring crd (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu authored May 2, 2022
1 parent c6c0de8 commit 383c423
Show file tree
Hide file tree
Showing 12 changed files with 494 additions and 510 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

GOPATH=$(shell go env GOPATH)
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

Expand All @@ -19,7 +19,7 @@ TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
Expand All @@ -29,7 +29,7 @@ default: build

GORELEASER_BIN = $(shell pwd)/bin/goreleaser
install-goreleaser: ## check license if not exist install go-lint tools
$(call go-get-tool,$(GORELEASER_BIN),github.com/goreleaser/goreleaser@latest)
$(call go-get-tool,$(GORELEASER_BIN),github.com/goreleaser/goreleaser@v1.6.3)


build: SHELL:=/bin/bash
Expand Down Expand Up @@ -58,7 +58,7 @@ filelicense: install-addlicense

DEEPCOPY_BIN = $(shell pwd)/bin/deepcopy-gen
install-deepcopy: ## check license if not exist install go-lint tools
$(call go-get-tool,$(DEEPCOPY_BIN),k8s.io/code-generator/cmd/deepcopy-gen@latest)
$(call go-get-tool,$(DEEPCOPY_BIN),k8s.io/code-generator/cmd/deepcopy-gen@v0.23.6)

HEAD_FILE := hack/boilerplate.go.txt
INPUT_DIR := github.com/labring/endpoints-operator/api/network/v1beta1
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
domain: sealyun.com
domain: sealos.io
repo: endpoints-operator
version: "2"
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

> 对于集群内访问集群外部服务场景使用固定的endpoint维护增加探活功能
### 注意事项:

v0.1.1 版本的数据是sealyun.com的domain
v0.1.2 之后所有的domain都是sealos.io

也可以手动执行一下脚本,namespace为xxx
```shell
for cep in $(kubectl get cep -n xxx -o jsonpath={.items[*].metadata.name});do kubectl patch cep -n xxx --type='json' -p='[{"op": "replace", "path": "/metadata/finalizers", "value":[]}]' $cep;done
```

升级资源之前最好先备份一下cr删除之后再重新创建即可。

## 背景

- 在实际使用中,两个K8s集群之间的服务经常有互相访问和访问集群外部某些服务的需求,通常的解决方案为手动维护固定的Services和Endpoints或者直接在业务配置中写死IP,在这时候,是没有对外部服务进行探活的功能的,无法做到高可用。如果需要高可用一般是引入外部高可用LB来解决,但这样增加了复杂度,且好多公司不具备引入条件,不是最优解决方案。
Expand Down Expand Up @@ -45,7 +57,7 @@ helm install -n kube-system endpoints-operator config/charts/endpoints-operator
## Usage

```yaml
apiVersion: sealyun.com/v1beta1
apiVersion: sealos.io/v1beta1
kind: ClusterEndpoint
metadata:
name: wordpress
Expand Down
2 changes: 1 addition & 1 deletion api/network/v1beta1/doc.go

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

2 changes: 1 addition & 1 deletion api/network/v1beta1/register.go

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

235 changes: 235 additions & 0 deletions config/charts/endpoints-operator/crds/sealos.io_clusterendpoints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
creationTimestamp: null
name: clusterendpoints.sealos.io
spec:
additionalPrinterColumns:
- JSONPath: .metadata.creationTimestamp
description: The creation date
name: Age
type: date
- JSONPath: .status.phase
description: The status
name: Status
type: string
group: sealos.io
names:
kind: ClusterEndpoint
listKind: ClusterEndpointList
plural: clusterendpoints
shortNames:
- cep
singular: clusterendpoint
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: ClusterEndpoint is the Schema for the tests API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ClusterEndpointSpec defines the desired state of ClusterEndpoint
properties:
clusterIP:
type: string
hosts:
items:
type: string
type: array
periodSeconds:
description: How often (in seconds) to perform the probe. Default to
10 seconds. Minimum value is 1.
format: int32
type: integer
ports:
items:
description: ServicePort contains information on service's port.
properties:
failureThreshold:
description: Minimum consecutive failures for the probe to be
considered failed after having succeeded. Defaults to 3. Minimum
value is 1.
format: int32
type: integer
grpc:
description: GRPC specifies an action involving a GRPC port. This
is an alpha field and requires enabling GRPCContainerProbe feature
gate.
properties:
enable:
type: boolean
service:
description: "Service is the name of the service to place
in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
\n If this is not specified, the default behavior is defined
by gRPC."
type: string
required:
- enable
type: object
httpGet:
description: HTTPGet specifies the http request to perform.
properties:
httpHeaders:
description: Custom headers to set in the request. HTTP allows
repeated headers.
items:
description: HTTPHeader describes a custom header to be
used in HTTP probes
properties:
name:
description: The header field name
type: string
value:
description: The header field value
type: string
required:
- name
- value
type: object
type: array
path:
description: Path to access on the HTTP server.
type: string
scheme:
description: Scheme to use for connecting to the host. Defaults
to HTTP.
type: string
type: object
name:
description: The name of this port within the service. This must
be a DNS_LABEL. All ports within a ServiceSpec must have unique
names. When considering the endpoints for a Service, this must
match the 'name' field in the EndpointPort. Optional if only
one ServicePort is defined on this service.
type: string
port:
description: The port that will be exposed by this service.
format: int32
type: integer
protocol:
description: The IP protocol for this port. Supports "TCP", "UDP",
and "SCTP". Default is TCP.
type: string
successThreshold:
description: Minimum consecutive successes for the probe to be
considered successful after having failed. Defaults to 1. Must
be 1 for liveness and startup. Minimum value is 1.
format: int32
type: integer
targetPort:
description: Number or name of the port to access on the pods
targeted by the service. Number must be in the range 1 to 65535.
Name must be an IANA_SVC_NAME. If this is a string, it will
be looked up as a named port in the target Pod's container ports.
If this is not specified, the value of the 'port' field is used
(an identity map).
format: int32
type: integer
tcpSocket:
description: TCPSocket specifies an action involving a TCP port.
TCP hooks not yet supported
properties:
enable:
type: boolean
required:
- enable
type: object
timeoutSeconds:
description: 'Number of seconds after which the probe times out.
Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes'
format: int32
type: integer
udpSocket:
description: UDPSocketAction specifies an action involving a UDP
port. UDP hooks not yet supported
properties:
data:
description: UDP test data
items:
type: integer
type: array
enable:
type: boolean
required:
- enable
type: object
required:
- port
- targetPort
type: object
type: array
type: object
status:
description: ClusterEndpointStatus defines the observed state of ClusterEndpoint
properties:
conditions:
description: Conditions contains the different condition statuses for
this workspace.
items:
properties:
lastHeartbeatTime:
description: LastHeartbeatTime is the last time this condition
was updated.
format: date-time
type: string
lastTransitionTime:
description: LastTransitionTime is the last time the condition
changed from one status to another.
format: date-time
type: string
message:
description: Message is a human-readable message indicating details
about the last status change.
type: string
reason:
description: Reason is a (brief) reason for the condition's last
status change.
type: string
status:
description: Status is the status of the condition. One of True,
False, Unknown.
type: string
type:
type: string
required:
- status
- type
type: object
type: array
phase:
description: Phase is the recently observed lifecycle phase of the
cluster endpoints.
type: string
required:
- conditions
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit 383c423

Please sign in to comment.