Chore: remove outdated apis(v1alppha2 ApplicationConfiguration Component, and HealthScope, Rollout) (#6041)

* remove outdated api

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* fix rt test: no component rt

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* recover context.revision to component hash

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

---------

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive
2023-06-01 09:32:49 +08:00
committed by GitHub
parent d6788f12dd
commit dd899c2b39
284 changed files with 517 additions and 66926 deletions

View File

@@ -17,7 +17,6 @@ import (
"context"
"fmt"
"os"
"strings"
"time"
. "github.com/onsi/ginkgo/v2"
@@ -133,71 +132,5 @@ var _ = PDescribe("Test MultiCluster Rollout", func() {
}, 30*time.Second).Should(BeNil())
verifySucceed(componentName + "-v1")
})
// HealthScopeController will not work properly with authentication module now
PIt("Test Rollout with health check policy, guarantee health scope controller work ", func() {
app := &v1beta1.Application{}
appYaml, err := os.ReadFile("./testdata/app/multi-cluster-health-policy.yaml")
Expect(err).Should(Succeed())
Expect(yaml.Unmarshal([]byte(appYaml), app)).Should(Succeed())
app.SetNamespace(namespace)
err = k8sClient.Create(hubCtx, app)
Expect(err).Should(Succeed())
verifySucceed(componentName + "-v1")
Eventually(func() error {
checkApp := v1beta1.Application{}
if err := k8sClient.Get(hubCtx, types.NamespacedName{Namespace: namespace, Name: app.Name}, &checkApp); err != nil {
return err
}
if len(checkApp.Status.Services) == 0 {
return fmt.Errorf("app status service haven't write back")
}
compStatus := checkApp.Status.Services[0]
if compStatus.Env != "staging" {
return fmt.Errorf("comp status env miss-match")
}
if !compStatus.Healthy {
return fmt.Errorf("comp status not healthy")
}
if !strings.Contains(compStatus.Message, "Ready:2/2") {
return fmt.Errorf("comp status workload check don't work")
}
return nil
}, 30*time.Second).Should(BeNil())
By("update application to v2")
checkApp := &v1beta1.Application{}
Eventually(func() error {
if err := k8sClient.Get(hubCtx, types.NamespacedName{Namespace: namespace, Name: app.Name}, checkApp); err != nil {
return err
}
checkApp.Spec.Components[0].Properties.Raw = []byte(`{"image": "stefanprodan/podinfo:5.0.2"}`)
if err := k8sClient.Update(hubCtx, checkApp); err != nil {
return err
}
return nil
}, 30*time.Second).Should(BeNil())
verifySucceed(componentName + "-v2")
Eventually(func() error {
// Note: KubeVela will only check the workload of the target revision
checkApp := v1beta1.Application{}
if err := k8sClient.Get(hubCtx, types.NamespacedName{Namespace: namespace, Name: app.Name}, &checkApp); err != nil {
return err
}
if len(checkApp.Status.Services) == 0 {
return fmt.Errorf("app status service haven't write back")
}
compStatus := checkApp.Status.Services[0]
if compStatus.Env != "staging" {
return fmt.Errorf("comp status env miss-match")
}
if !compStatus.Healthy {
return fmt.Errorf("comp status not healthy")
}
if !strings.Contains(compStatus.Message, "Ready:2/2") {
return fmt.Errorf("comp status workload check don't work")
}
return nil
}, 60*time.Second).Should(BeNil())
})
})
})

View File

@@ -40,7 +40,7 @@ import (
oamcomm "github.com/oam-dev/kubevela/apis/core.oam.dev/common"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha1"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
"github.com/oam-dev/kubevela/pkg/controller/core.oam.dev/v1alpha2/application"
"github.com/oam-dev/kubevela/pkg/controller/core.oam.dev/v1beta1/application"
"github.com/oam-dev/kubevela/pkg/oam"
"github.com/oam-dev/kubevela/pkg/workflow/operation"
)

View File

@@ -1,244 +0,0 @@
/*
Copyright 2021 The KubeVela Authors.
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
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package controllers_test
import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
"github.com/oam-dev/kubevela/pkg/oam/util"
utilcommon "github.com/oam-dev/kubevela/pkg/utils/common"
)
var _ = PDescribe("HealthScope", func() {
ctx := context.Background()
var namespace string
var ns corev1.Namespace
BeforeEach(func() {
namespace = randomNamespaceName("health-scope-test")
ns = corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
},
}
Expect(k8sClient.Create(ctx, &ns)).Should(Succeed())
// create health scope definition
sd := v1alpha2.ScopeDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: "healthscope.core.oam.dev",
Namespace: "vela-system",
},
Spec: v1alpha2.ScopeDefinitionSpec{
AllowComponentOverlap: true,
WorkloadRefsPath: "spec.workloadRefs",
Reference: common.DefinitionReference{
Name: "healthscope.core.oam.dev",
},
},
}
logf.Log.Info("Creating health scope definition")
Expect(k8sClient.Create(ctx, &sd)).Should(SatisfyAny(BeNil(), &util.AlreadyExistMatcher{}))
})
AfterEach(func() {
logf.Log.Info("Clean up resources")
Expect(k8sClient.DeleteAllOf(ctx, &v1alpha2.HealthScope{}, client.InNamespace(namespace))).Should(BeNil())
// delete the namespace with all its resources
Expect(k8sClient.Delete(ctx, &ns, client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(BeNil())
})
It("Test an application with health policy", func() {
By("Apply a healthy application")
var newApp v1beta1.Application
var healthyAppName, unhealthyAppName string
Expect(utilcommon.ReadYamlToObject("testdata/app/app_healthscope.yaml", &newApp)).Should(BeNil())
newApp.Namespace = namespace
convertToLegacyIngressTrait(&newApp)
Eventually(func() error {
return k8sClient.Create(ctx, newApp.DeepCopy())
}, 10*time.Second, 500*time.Millisecond).Should(Succeed())
healthyAppName = newApp.Name
By("Get Application latest status")
Eventually(
func() *common.Revision {
var app v1beta1.Application
k8sClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: healthyAppName}, &app)
if app.Status.LatestRevision != nil {
return app.Status.LatestRevision
}
return nil
},
time.Second*30, time.Millisecond*500).ShouldNot(BeNil())
By("Apply an unhealthy application")
newApp = v1beta1.Application{}
Expect(utilcommon.ReadYamlToObject("testdata/app/app_healthscope_unhealthy.yaml", &newApp)).Should(BeNil())
newApp.Namespace = namespace
convertToLegacyIngressTrait(&newApp)
Eventually(func() error {
return k8sClient.Create(ctx, newApp.DeepCopy())
}, 10*time.Second, 500*time.Millisecond).Should(Succeed())
unhealthyAppName = newApp.Name
By("Get Application latest status")
Eventually(
func() *common.Revision {
var app v1beta1.Application
k8sClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: unhealthyAppName}, &app)
if app.Status.LatestRevision != nil {
return app.Status.LatestRevision
}
return nil
},
time.Second*30, time.Millisecond*500).ShouldNot(BeNil())
By("Verify the healthy health scope")
healthScopeObject := client.ObjectKey{
Name: "app-healthscope",
Namespace: namespace,
}
healthScope := &v1alpha2.HealthScope{}
Expect(k8sClient.Get(ctx, healthScopeObject, healthScope)).Should(Succeed())
Eventually(
func() v1alpha2.ScopeHealthCondition {
*healthScope = v1alpha2.HealthScope{}
k8sClient.Get(ctx, healthScopeObject, healthScope)
return healthScope.Status.ScopeHealthCondition
},
time.Second*60, time.Millisecond*500).Should(Equal(v1alpha2.ScopeHealthCondition{
HealthStatus: v1alpha2.StatusHealthy,
Total: int64(2),
HealthyWorkloads: int64(2),
}))
By("Verify the healthy application status")
Eventually(func() error {
healthyApp := &v1beta1.Application{}
if err := k8sClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: healthyAppName}, healthyApp); err != nil {
return err
}
appCompStatuses := healthyApp.Status.Services
if len(appCompStatuses) != 2 {
return fmt.Errorf("expect 2 comp statuses, but got %d", len(appCompStatuses))
}
compSts1 := appCompStatuses[0]
if !compSts1.Healthy || !strings.Contains(compSts1.Message, "Ready:1/1") {
return fmt.Errorf("expect healthy comp, but %v is unhealthy, msg: %q", compSts1.Name, compSts1.Message)
}
if len(compSts1.Traits) != 1 {
return fmt.Errorf("expect 1 trait statuses, but got %d", len(compSts1.Traits))
}
if !strings.Contains(compSts1.Traits[0].Message, "Visiting URL") {
return fmt.Errorf("trait message isn't right, now is %s", compSts1.Traits[0].Message)
}
return nil
}, time.Second*30, time.Millisecond*500).Should(Succeed())
By("Verify the unhealthy health scope")
healthScopeObject = client.ObjectKey{
Name: "app-healthscope-unhealthy",
Namespace: namespace,
}
healthScope = &v1alpha2.HealthScope{}
Expect(k8sClient.Get(ctx, healthScopeObject, healthScope)).Should(Succeed())
Eventually(
func() v1alpha2.ScopeHealthCondition {
*healthScope = v1alpha2.HealthScope{}
k8sClient.Get(ctx, healthScopeObject, healthScope)
return healthScope.Status.ScopeHealthCondition
},
time.Second*60, time.Millisecond*500).Should(Equal(v1alpha2.ScopeHealthCondition{
HealthStatus: v1alpha2.StatusUnhealthy,
Total: int64(2),
UnhealthyWorkloads: int64(1),
HealthyWorkloads: int64(1),
}))
By("Verify the unhealthy application status")
Eventually(func() error {
unhealthyApp := &v1beta1.Application{}
if err := k8sClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: healthyAppName}, unhealthyApp); err != nil {
return err
}
appCompStatuses := unhealthyApp.Status.Services
if len(appCompStatuses) != 2 {
return fmt.Errorf("expect 2 comp statuses, but got %d", len(appCompStatuses))
}
for _, cSts := range appCompStatuses {
if cSts.Name == "my-server-unhealthy" {
unhealthyCompSts := cSts
if unhealthyCompSts.Healthy || !strings.Contains(unhealthyCompSts.Message, "Ready:0/1") {
return fmt.Errorf("expect unhealthy comp, but %s is unhealthy, msg: %q", unhealthyCompSts.Name, unhealthyCompSts.Message)
}
}
}
return nil
}, time.Second*30, time.Millisecond*500).Should(Succeed())
})
})
// convertToLegacyIngressTrait convert app's gateway trait to ingress
func convertToLegacyIngressTrait(app *v1beta1.Application) {
if noNetworkingV1 {
for i := range app.Spec.Components {
for j := range app.Spec.Components[i].Traits {
if app.Spec.Components[i].Traits[j].Type == "gateway" {
app.Spec.Components[i].Traits[j].Type = "ingress"
}
props := app.Spec.Components[i].Traits[j].Properties
propMap, err := util.RawExtension2Map(props)
if err != nil {
return
}
newPropMap := map[string]interface{}{}
for k := range propMap {
if k != "class" {
newPropMap[k] = propMap[k]
}
}
ext, err := json.Marshal(newPropMap)
if err != nil {
return
}
app.Spec.Components[i].Traits[j].Properties = &runtime.RawExtension{
Raw: ext,
}
}
}
}
}

View File

@@ -45,7 +45,7 @@ import (
core "github.com/oam-dev/kubevela/apis/core.oam.dev"
commontypes "github.com/oam-dev/kubevela/apis/core.oam.dev/common"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
"github.com/oam-dev/kubevela/pkg/oam/util"
// +kubebuilder:scaffold:imports
)
@@ -55,15 +55,6 @@ var scheme = runtime.NewScheme()
var roleName = "oam-example-com"
var roleBindingName = "oam-role-binding"
var (
noNetworkingV1 bool
)
// A DefinitionExtension is an Object type for xxxDefinitin.spec.extension
type DefinitionExtension struct {
Alias string `json:"alias,omitempty"`
}
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
@@ -104,12 +95,12 @@ var _ = BeforeSuite(func() {
By("Finished setting up test environment")
// create workload definition for 'deployments'
wdDeploy := v1alpha2.WorkloadDefinition{
wdDeploy := v1beta1.WorkloadDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: "deployments.apps",
Namespace: "vela-system",
},
Spec: v1alpha2.WorkloadDefinitionSpec{
Spec: v1beta1.WorkloadDefinitionSpec{
Reference: commontypes.DefinitionReference{
Name: "deployments.apps",
},

View File

@@ -1,51 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-healthscope
spec:
components:
- name: my-server-1
type: webservice
properties:
cmd:
- node
- server.js
image: oamdev/testapp:v1
port: 8080
traits:
- type: gateway
properties:
class: traefik
domain: test.my.domain
http:
"/": 8080
- name: my-server-2
type: webservice
properties:
cmd:
- node
- server.js
image: oamdev/testapp:v1
port: 8080
traits:
- type: gateway
properties:
class: traefik
domain: test.my.domain
http:
"/": 8080
policies:
- name: app-healthscope
type: health
properties:
probeInterval: 5
workflow:
steps:
- name: apply-my-server-1
type: apply-component
properties:
component: my-server-1
- name: apply-my-server-2
type: apply-component
properties:
component: my-server-2

View File

@@ -1,34 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-healthscope-unhealthy
spec:
components:
- name: my-server-unhealthy
type: webservice
properties:
cmd:
- node
- server.js
image: oamdev/testapp:boom # make it unhealthy
port: 8080
- name: my-server
type: webservice
properties:
cmd:
- node
- server.js
image: oamdev/testapp:v1
port: 8080
traits:
- type: gateway
properties:
class: traefik
domain: test.my.domain
http:
"/": 8080
policies:
- name: app-healthscope-unhealthy
type: health
properties:
probeInterval: 5

View File

@@ -1,14 +0,0 @@
apiVersion: core.oam.dev/v1alpha2
kind: ApplicationConfiguration
metadata:
name: example-appconfig
namespace: component-versioning-test
spec:
components:
- componentName: example-component
traits:
- trait:
apiVersion: example.com/v1
kind: Bar
spec:
foo: bar

View File

@@ -1,11 +0,0 @@
apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
name: example-component
namespace: component-versioning-test
spec:
workload:
apiVersion: example.com/v1
kind: Bar
spec:
key: v1

View File

@@ -1,11 +0,0 @@
apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
name: example-component
namespace: component-versioning-test
spec:
workload:
apiVersion: example.com/v1
kind: Bar
spec:
key: v2

View File

@@ -1,8 +0,0 @@
apiVersion: core.oam.dev/v1alpha2
kind: TraitDefinition
metadata:
name: bars.example.com
namespace: oam-runtime-system
spec:
definitionRef:
name: bars.example.com

View File

@@ -1,9 +0,0 @@
apiVersion: core.oam.dev/v1alpha2
kind: TraitDefinition
metadata:
name: bars.example.com
namespace: oam-runtime-system
spec:
revisionEnabled: true
definitionRef:
name: bars.example.com

View File

@@ -1,8 +0,0 @@
apiVersion: core.oam.dev/v1alpha2
kind: WorkloadDefinition
metadata:
name: bars.example.com
namespace: vela-system
spec:
definitionRef:
name: bars.example.com

View File

@@ -1,17 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: test-e2e-rolling
annotations:
"app.oam.dev/rollout-template": "true"
spec:
components:
- name: metrics-provider
type: clonesetservice
properties:
cmd:
- ./podinfo
- stress-cpu=1
image: stefanprodan/podinfo:4.0.3
port: 8080
updateStrategyType: InPlaceOnly

View File

@@ -1,17 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: test-e2e-rolling
annotations:
"app.oam.dev/rollout-template": "true"
spec:
components:
- name: metrics-provider
type: clonesetservice
properties:
cmd:
- ./podinfo
- stress-cpu=1
image: stefanprodan/podinfo:5.0.2
port: 8080
updateStrategyType: InPlaceOnly

View File

@@ -1,23 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: test-e2e-rolling
annotations:
"app.oam.dev/rollout-template": "true"
spec:
components:
- name: metrics-provider
type: clonesetservice
properties:
cmd:
- ./podinfo
- stress-cpu=1
image: stefanprodan/podinfo:4.0.3
port: 8080
updateStrategyType: InPlaceOnly
traits:
- type: ingress
properties:
domain: test.example.com
http:
"/": 8080

View File

@@ -1,23 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: test-e2e-rolling
annotations:
"app.oam.dev/rollout-template": "true"
spec:
components:
- name: metrics-provider
type: clonesetservice
properties:
cmd:
- ./podinfo
- stress-cpu=1
image: stefanprodan/podinfo:5.0.2
port: 8080
updateStrategyType: InPlaceOnly
traits:
- type: ingress
properties:
domain: test-1.example.com
http:
"/": 8080

View File

@@ -1,18 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: AppRollout
metadata:
name: rolling-e2e-test
spec:
# application (revision) reference
targetAppRevisionName: test-e2e-rolling-v2
sourceAppRevisionName: test-e2e-rolling-v1
# HPA reference (optional)
componentList:
- metrics-provider
rolloutPlan:
rolloutStrategy: "IncreaseFirst"
rolloutBatches:
- replicas: 10%
- replicas: 40%
- replicas: 50%
batchPartition: 2

View File

@@ -1,14 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: AppRollout
metadata:
name: rolling-e2e-test
spec:
# application (revision) reference
targetAppRevisionName: test-e2e-rolling-v1
componentList:
- metrics-provider
rolloutPlan:
rolloutStrategy: "IncreaseFirst"
rolloutBatches:
- replicas: 2
batchPartition: 3

View File

@@ -1,110 +0,0 @@
# Code generated by KubeVela templates. DO NOT EDIT.
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
name: clonesetservice
namespace: vela-system
annotations:
definition.oam.dev/description: "Describes long-running, scalable, containerized services that have a stable network endpoint to receive external network traffic from customers.
If workload type is skipped for any service defined in Appfile, it will be defaulted to `webservice` type."
spec:
workload:
definition:
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
schematic:
cue:
template: |
output: {
apiVersion: "apps.kruise.io/v1alpha1"
kind: "CloneSet"
metadata: labels: {
"app.oam.dev/component": context.name
}
spec: {
if parameter["replicas"] != _|_ {
replicas: parameter.replicas
}
selector: matchLabels: {
"app.oam.dev/component": context.name
}
template: {
metadata: labels: {
"app.oam.dev/component": context.name
}
spec: {
containers: [{
name: context.name
image: parameter.image
if parameter["cmd"] != _|_ {
command: parameter.cmd
}
if parameter["env"] != _|_ {
env: parameter.env
}
if context["config"] != _|_ {
env: context.config
}
ports: [{
containerPort: parameter.port
}]
if parameter["cpu"] != _|_ {
resources: {
limits:
cpu: parameter.cpu
requests:
cpu: parameter.cpu
}
}
}]
}
}
if parameter["updateStrategyType"] != _|_ {
updateStrategy: {
type: parameter.updateStrategyType
}
}
}
}
parameter: {
// +usage=Which image would you like to use for your service
// +short=i
image: string
// +usage=Commands to run in the container
cmd?: [...string]
// +usage=Which port do you want customer traffic sent to
// +short=p
port: *80 | int
// +usage=Define arguments by using environment variables
env?: [...{
// +usage=Environment variable name
name: string
// +usage=The value of the environment variable
value?: string
// +usage=Specifies a source the value of this var should come from
valueFrom?: {
// +usage=Selects a key of a secret in the pod's namespace
secretKeyRef: {
// +usage=The name of the secret in the pod's namespace to select from
name: string
// +usage=The key of the secret to select from. Must be a valid secret key
key: string
}
}
}]
// +usage=Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core)
cpu?: string
// +usage=Cloneset updateStrategy, candidates are `ReCreate`/`InPlaceIfPossible`/`InPlaceOnly`
updateStrategyType?: string
// +usage=Number of pods in the cloneset
replicas?: int
}

View File

@@ -1,110 +0,0 @@
# Code generated by KubeVela templates. DO NOT EDIT.
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
name: clonesetservice
namespace: vela-system
annotations:
definition.oam.dev/description: "Describes long-running, scalable, containerized services that have a stable network endpoint to receive external network traffic from customers.
If workload type is skipped for any service defined in Appfile, it will be defaulted to `webservice` type."
spec:
workload:
definition:
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
schematic:
cue:
template: |
output: {
apiVersion: "apps.kruise.io/v1alpha1"
kind: "CloneSet"
metadata: labels: {
"app.oam.dev/component": context.name
}
spec: {
if parameter["replicas"] != _|_ {
replicas: parameter.replicas
}
selector: matchLabels: {
"app.oam.dev/component": context.name
}
template: {
metadata: labels: {
"app.oam.dev/component": context.name
}
spec: {
containers: [{
name: context.name
image: parameter.image
if parameter["cmd"] != _|_ {
command: parameter.cmd
}
if parameter["env"] != _|_ {
env: parameter.env
}
if context["config"] != _|_ {
env: context.config
}
ports: [{
containerPort: parameter.port
}]
if parameter["cpu"] != _|_ {
resources: {
limits:
cpu: parameter.cpu
requests:
cpu: parameter.cpu
}
}
}]
}
}
if parameter["updateStrategyType"] != _|_ {
updateStrategy: {
type: parameter.updateStrategyType
}
}
}
}
parameter: {
// +usage=Which image would you like to use for your service
// +short=i
image: string
// +usage=Commands to run in the container
cmd?: [...string]
// +usage=Which port do you want customer traffic sent to
// +short=p
port: *80 | int
// +usage=Define arguments by using environment variables
env?: [...{
// +usage=Environment variable name
name: string
// +usage=The value of the environment variable
value?: string
// +usage=Specifies a source the value of this var should come from
valueFrom?: {
// +usage=Selects a key of a secret in the pod's namespace
secretKeyRef: {
// +usage=The name of the secret in the pod's namespace to select from
name: string
// +usage=The key of the secret to select from. Must be a valid secret key
key: string
}
}
}]
// +usage=Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core)
cpu?: string
// +usage=Cloneset updateStrategy, candidates are `ReCreate`/`InPlaceIfPossible`/`InPlaceOnly`
updateStrategyType?: string
// +usage=Number of pods in the cloneset
replicas?: int
}

View File

@@ -1,15 +0,0 @@
apiVersion: standard.oam.dev/v1alpha1
kind: Rollout
metadata:
name: rolling-test
spec:
# application (revision) reference
targetRevisionName: metrics-provider-v1
# HPA reference (optional)
componentName: metrics-provider
rolloutPlan:
rolloutStrategy: "IncreaseFirst"
rolloutBatches:
- replicas: 3
- replicas: 2
targetSize: 5

View File

@@ -1,43 +0,0 @@
apiVersion: apps/v1
data:
apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
creationTimestamp: null
name: metrics-provider
spec:
workload:
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: metrics-provider
labels:
app.oam.dev/component: metrics-provider
spec:
replicas: 5
selector:
matchLabels:
app.oam.dev/component: metrics-provider
template:
metadata:
labels:
app.oam.dev/component: metrics-provider
spec:
containers:
- command:
- ./podinfo
- stress-cpu=1
image: stefanprodan/podinfo:4.0.3
name: metrics-provider
ports:
- containerPort: 8080
updateStrategy:
type: InPlaceOnly
status:
observedGeneration: 0
kind: ControllerRevision
metadata:
name: metrics-provider-v1
labels:
controller.oam.dev/component: metrics-provider
revision: 1

View File

@@ -1,43 +0,0 @@
apiVersion: apps/v1
data:
apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
creationTimestamp: null
name: metrics-provider
spec:
workload:
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: metrics-provider
labels:
app.oam.dev/component: metrics-provider
spec:
replicas: 5
selector:
matchLabels:
app.oam.dev/component: metrics-provider
template:
metadata:
labels:
app.oam.dev/component: metrics-provider
spec:
containers:
- command:
- ./podinfo
- stress-cpu=1
image: stefanprodan/podinfo:5.0.2
name: metrics-provider
ports:
- containerPort: 8080
updateStrategy:
type: InPlaceOnly
status:
observedGeneration: 0
kind: ControllerRevision
metadata:
name: metrics-provider-v2
labels:
controller.oam.dev/component: metrics-provider
revision: 1

View File

@@ -1,79 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: "Enable public web traffic for the component."
name: ingress
namespace: vela-system
spec:
status:
customStatus: |-
let igs = context.outputs.ingress.status.loadBalancer.ingress
if igs == _|_ {
message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
}
if len(igs) > 0 {
if igs[0].ip != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].ip == _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
}
healthPolicy: |
isHealth: len(context.outputs.service.spec.clusterIP) > 0
appliesToWorkloads:
- deployments.apps
podDisruptive: false
schematic:
cue:
template: |
// trait template can have multiple outputs in one trait
outputs: service: {
apiVersion: "v1"
kind: "Service"
metadata:
name: context.name
spec: {
selector: {
"app.oam.dev/component": context.name
}
ports: [
for k, v in parameter.http {
port: v
targetPort: v
},
]
}
}
outputs: ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
name: context.name
spec: {
rules: [{
host: parameter.domain
http: {
paths: [
for k, v in parameter.http {
path: k
backend: {
serviceName: context.name
servicePort: v
}
},
]
}
}]
}
}
parameter: {
// +usage=Specify the domain you want to expose
domain: string
// +usage=Specify the mapping relationship between the http path and the workload port
http: [string]: int
}

View File

@@ -1,16 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: rollout-trait-test
spec:
components:
- name: express-server
type: webservice
properties:
image: stefanprodan/podinfo:4.0.3
traits:
- type: rollout
properties:
targetSize: 2
firstBatchReplicas: 1
secondBatchReplicas: 1

View File

@@ -1,27 +0,0 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: rollout-trait-test
spec:
components:
- name: express-server
type: webservice
properties:
image: stefanprodan/podinfo:4.0.3
traits:
- type: rollout
properties:
targetSize: 2
firstBatchReplicas: 1
secondBatchReplicas: 1
- name: express-server-another
type: webservice
properties:
image: stefanprodan/podinfo:4.0.3
traits:
- type: rollout
properties:
targetSize: 2
firstBatchReplicas: 1
secondBatchReplicas: 1