Skip to content

Commit

Permalink
Merge pull request #19 from xishengcai/caixisheng
Browse files Browse the repository at this point in the history
support node port ,remove statefulset
  • Loading branch information
caixisheng authored May 26, 2022
2 parents 748c8d9 + 1ca7502 commit 3cfa017
Show file tree
Hide file tree
Showing 28 changed files with 224 additions and 247 deletions.
3 changes: 3 additions & 0 deletions apis/core/v1alpha2/core_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ type ApplicationConfigurationComponent struct {
// +optional
ComponentName string `json:"componentName,omitempty"`

// WorkloadType default type is deployment
//WorkloadType string `json:"WorkloadType,omitempty"`

// RevisionName of a specific component revision to which to bind
// ApplicationConfiguration. This is mutually exclusive with componentName.
// +optional
Expand Down
59 changes: 47 additions & 12 deletions apis/core/v1alpha2/core_workload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,32 @@ type ContainerConfigFile struct {
SubPath bool `json:"subPath,omitempty"`
}

// A TransportProtocol represents a transport layer protocol.
type TransportProtocol string

// Transport protocols.
const (
TransportProtocolTCP TransportProtocol = "TCP"
TransportProtocolUDP TransportProtocol = "UDP"
)

// A ContainerPort specifies a port that is exposed by a container.
type ContainerPort struct {
Name string `json:"name"`
// Port number. Must be unique within its container.
Port int32 `json:"containerPort"`
// TODO(negz): Use +kubebuilder:default marker to default Protocol to TCP

// once we're generating v1 CRDs.
// Protocol used by the server listening on this port.
// +kubebuilder:validation:Enum=TCP;UDP
// +kubebuilder:validation:Enum=TCP;UDP;SCTP
// +optional
Protocol *TransportProtocol `json:"protocol,omitempty"`
Protocol *corev1.Protocol `json:"protocol,omitempty"`

// Number of port to expose on the host.
// If specified, this must be a valid port number, 0 < x < 65536.
// If HostNetwork is specified, this must match ContainerPort.
// Most containers do not need this.
// +optional
HostPort int32 `json:"hostPort,omitempty" protobuf:"varint,2,opt,name=hostPort"`

// The port on each node on which this service is exposed when type=NodePort or LoadBalancer.
// Usually assigned by the system. If specified, it will be allocated to the service
// if unused or else creation of the service will fail.
// Default is to auto-allocate a port if the ServiceType of this Service requires one.
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
// +optional
NodePort int32 `json:"nodePort,omitempty" protobuf:"varint,5,opt,name=nodePort"`
}

// An ExecProbe probes a container's health by executing a command.
Expand Down Expand Up @@ -356,6 +355,18 @@ type Container struct {
ImagePullSecret *string `json:"imagePullSecret,omitempty"`
}

type WorkloadType string

const (
StatefulSetWorkloadType = "statefulset"
DeploymentWorkloadType = "deployment"
ServiceWorkloadType = "service"
)

const (
ForceUpdateTimestamp string = "forceUpdateTimestamp"
)

// A ContainerizedWorkloadSpec defines the desired state of a
// ContainerizedWorkload.
type ContainerizedWorkloadSpec struct {
Expand Down Expand Up @@ -391,6 +402,30 @@ type ContainerizedWorkloadSpec struct {
// Dependency components
// +optional
Dependency []Dependency `json:"dependency,omitempty"`

// Type support deployment and statefulSet
Type WorkloadType `json:"type,omitempty"`

// ForceUpdateTimestamp
// +optional
ForceUpdateTimestamp string `json:"forceUpdateTimestamp,omitempty"`

// ServiceType determines how the Service is exposed. Defaults to ClusterIP. Valid
// options are ExternalName, ClusterIP, NodePort, and LoadBalancer.
// "ExternalName" maps to the specified externalName.
// "ClusterIP" allocates a cluster-internal IP address for load-balancing to
// endpoints. Endpoints are determined by the selector or if that is not
// specified, by manual construction of an Endpoints object. If clusterIP is
// "None", no virtual IP is allocated and the endpoints are published as a
// set of endpoints rather than a stable IP.
// "NodePort" builds on ClusterIP and allocates a port on every node which
// routes to the clusterIP.
// "LoadBalancer" builds on NodePort and creates an
// external load-balancer (if supported in the current cloud) which routes
// to the clusterIP.
// More info: https://kubernetes.io/docs/concepts/services-networking/service/
// +optional
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
}

type Dependency struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/core/v1alpha2/zz_generated.deepcopy.go

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

5 changes: 3 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ if [ -z "$IMAGE_NAME" ]; then
fi

if [ -z "$VERSION" ]; then
VERSION='v100r001c02b061'
VERSION='v100r001c02b081'
fi

if [ -z "$IMAGE_REPO" ]; then
IMAGE_REPO='registry.cn-beijing.aliyuncs.com/launcher-agent-only-test'
# IMAGE_REPO='registry.cn-beijing.aliyuncs.com/launcher-agent-only-dev'
IMAGE_REPO='registry.cn-hangzhou.aliyuncs.com/launcher-agent-only-test'
fi

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/${BIN_FILE} ./main.go
Expand Down
2 changes: 1 addition & 1 deletion charts/oam-kubernetes-runtime/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.0.1
version: 0.81.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,16 @@ spec:
type: integer
name:
type: string
nodePort:
description: 'The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one. More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport'
format: int32
type: integer
protocol:
description: 'TODO(negz): Use +kubebuilder:default marker to default Protocol to TCP once we''re generating v1 CRDs. Protocol used by the server listening on this port.'
description: once we're generating v1 CRDs. Protocol used by the server listening on this port.
enum:
- TCP
- UDP
- TCP
- UDP
- SCTP
type: string
required:
- containerPort
Expand Down Expand Up @@ -445,6 +450,9 @@ spec:
- name
type: object
type: array
forceUpdateTimestamp:
description: ForceUpdateTimestamp
type: string
initContainers:
description: InitContainers of which this workload initContainers.
items:
Expand Down Expand Up @@ -630,11 +638,16 @@ spec:
type: integer
name:
type: string
nodePort:
description: 'The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one. More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport'
format: int32
type: integer
protocol:
description: 'TODO(negz): Use +kubebuilder:default marker to default Protocol to TCP once we''re generating v1 CRDs. Protocol used by the server listening on this port.'
description: once we're generating v1 CRDs. Protocol used by the server listening on this port.
enum:
- TCP
- UDP
- TCP
- UDP
- SCTP
type: string
required:
- containerPort
Expand Down Expand Up @@ -845,6 +858,12 @@ spec:
serviceMesh:
description: check add istio label
type: boolean
serviceType:
description: 'ServiceType determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. "ExternalName" maps to the specified externalName. "ClusterIP" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is "None", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. "NodePort" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. "LoadBalancer" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/'
type: string
type:
description: Type support deployment and statefulSet
type: string
required:
- containers
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ spec:
description: It's either PVC or HostPath
type: string
required:
- name
- name
- path
type: object
type: array
Expand Down
3 changes: 2 additions & 1 deletion examples/configmap/sample_component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ spec:
apiVersion: core.oam.dev/v1alpha2
kind: ContainerizedWorkload
spec:
forceUpdateTimestamp: v1
nodeSelector:
kubernetes.io/arch: amd64
containers:
- name: nginx
image: nginx
config:
- path: /opt/xxx.log
value: dddddaaaaaa
value: xxaxxx
subPath: true
- path: /opt/abc.log
value: xxxxj
Expand Down
3 changes: 3 additions & 0 deletions examples/containerized-workload-deploy/sample_component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ spec:
apiVersion: core.oam.dev/v1alpha2
kind: ContainerizedWorkload
spec:
forceUpdateTimestamp: xxxx3
containers:
- name: wordpress
image: wordpress:4.6.1-apache
Expand All @@ -22,8 +23,10 @@ spec:
resources:
cpu:
required: "60m"
limits: "100m"
memory:
required: "60Mi"
limits: "100Mi"
parameters:
- name: instance-name
required: true
Expand Down
37 changes: 0 additions & 37 deletions examples/containerized-workload-sts/sample_application_config.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions examples/containerized-workload-sts/sample_component.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions examples/sts-configmap/sample_application_config.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions examples/sts-configmap/sample_component.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/volumeclaims/sample_application_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
paths:
- path: /var/log/a
name: html-2
persistentVolumeClaim: hp-1
persistentVolumeClaim: sc-2

volumeClaims:
- type: StorageClass
Expand Down
23 changes: 23 additions & 0 deletions examples/workload-node-port/sample_application_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: core.oam.dev/v1alpha2
kind: ApplicationConfiguration
metadata:
name: example-node-port
spec:
components:
- componentName: example-component
parameterValues:
- name: image
value: wordpress:php7.2
traits:
- trait:
apiVersion: core.oam.dev/v1alpha2
kind: ManualScalerTrait
metadata:
name: example-appconfig-trait
spec:
replicaCount: 3
scopes:
- scopeRef:
apiVersion: core.oam.dev/v1alpha2
kind: HealthScope
name: example-health-scope
Loading

0 comments on commit 3cfa017

Please sign in to comment.