Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

yurt ingress use helm reconcile #124

Closed
wants to merge 1 commit into from
Closed
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
114 changes: 114 additions & 0 deletions charts/yurt-app-manager/crds/apps.openyurt.io_yurtingresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,120 @@ spec:
type: object
type: object
served: true
storage: false
subresources:
status: {}
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha2
schema:
openAPIV3Schema:
description: YurtIngress is the Schema for the yurtingresses 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: YurtIngressSpec defines the desired state of YurtIngress
properties:
enabled:
type: boolean
values:
x-kubernetes-preserve-unknown-fields: true
type: object
status:
description: YurtIngressStatus defines the observed state of YurtIngress
properties:
conditions:
description: Conditions holds the conditions for the HelmRelease.
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are:
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
\n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
lastAppliedRevision:
description: LastAppliedRevision is the revision of the last successfully
applied source.
type: string
status:
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,4 @@ webhooks:
- UPDATE
resources:
- yurtappdaemons
- clientConfig:
caBundle: Cg==
service:
name: {{ template "yurt-app-manager.name" . }}-webhook
namespace: {{ .Release.Namespace }}
path: /validate-apps-openyurt-io-v1alpha1-yurtingress
admissionReviewVersions:
- v1
sideEffects: None
failurePolicy: Fail
name: vyurtingress.kb.io
rules:
- apiGroups:
- apps.openyurt.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
- DELETE
resources:
- yurtingresses

20 changes: 20 additions & 0 deletions charts/yurt-app-manager/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,23 @@ rules:
- roles
verbs:
- '*'

# support helm install nginx-ingress
- apiGroups:
- apps
resources:
- replicasets
verbs:
- '*'
- apiGroups:
- networking.k8s.io
resources:
- ingressclasses
verbs:
- '*'
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- '*'
20 changes: 16 additions & 4 deletions cmd/yurt-app-manager/app/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/leaderelection/resourcelock"
Expand All @@ -38,6 +39,7 @@ import (
"github.com/openyurtio/yurt-app-manager/cmd/yurt-app-manager/options"
"github.com/openyurtio/yurt-app-manager/pkg/projectinfo"
appsv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1"
appsv1alpha2 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha2"
"github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1beta1"
extclient "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client"
"github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/constant"
Expand All @@ -57,6 +59,7 @@ var (
func init() {
_ = clientgoscheme.AddToScheme(scheme)
_ = appsv1alpha1.AddToScheme(scheme)
utilruntime.Must(appsv1alpha2.AddToScheme(scheme))
_ = v1beta1.AddToScheme(scheme)

_ = appsv1alpha1.AddToScheme(clientgoscheme.Scheme)
Expand All @@ -80,6 +83,10 @@ func NewCmdYurtAppManager(stopCh <-chan struct{}) *cobra.Command {

fmt.Printf("%s version: %#v\n", projectinfo.GetYurtAppManagerName(), projectinfo.Get())

if yurtAppOptions.WorkloadNamespace == "" {
yurtAppOptions.WorkloadNamespace = os.Getenv("POD_NAMESPACE")
}

cmd.Flags().VisitAll(func(flag *pflag.Flag) {
klog.V(1).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
})
Expand Down Expand Up @@ -150,7 +157,7 @@ func Run(opts *options.YurtAppOptions) {

setupLog.Info("setup controllers")

ctx := genOptCtx(opts.CreateDefaultPool)
ctx := genOptCtx(opts)
if err = controller.SetupWithManager(mgr, ctx); err != nil {
setupLog.Error(err, "unable to setup controllers")
os.Exit(1)
Expand All @@ -173,9 +180,14 @@ func Run(opts *options.YurtAppOptions) {

}

func genOptCtx(createDefaultPool bool) context.Context {
return context.WithValue(context.Background(),
constant.ContextKeyCreateDefaultPool, createDefaultPool)
func genOptCtx(opts *options.YurtAppOptions) context.Context {
ctx := context.WithValue(context.Background(),
constant.ContextKeyCreateDefaultPool, opts.CreateDefaultPool)

ctx = context.WithValue(ctx,
constant.ContextKeyWorkloadNamespace, opts.WorkloadNamespace)

return ctx
}

func setRestConfig(c *rest.Config) {
Expand Down
2 changes: 2 additions & 0 deletions cmd/yurt-app-manager/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type YurtAppOptions struct {
Namespace string
CreateDefaultPool bool
Version bool
WorkloadNamespace string
}

// NewYurtAppOptions creates a new YurtAppOptions with a default config.
Expand Down Expand Up @@ -64,6 +65,7 @@ func (o *YurtAppOptions) AddFlags(fs *pflag.FlagSet) {
fs.BoolVar(&o.EnablePprof, "enable-pprof", o.EnablePprof, "Enable pprof for controller manager.")
fs.StringVar(&o.LeaderElectionNamespace, "leader-election-namespace", o.LeaderElectionNamespace, "This determines the namespace in which the leader election configmap will be created, it will use in-cluster namespace if empty.")
fs.StringVar(&o.Namespace, "namespace", o.Namespace, "Namespace if specified restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.")
fs.StringVar(&o.WorkloadNamespace, "workloadNamespace", o.WorkloadNamespace, "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add description for the parameter.

fs.BoolVar(&o.CreateDefaultPool, "create-default-pool", o.CreateDefaultPool, "Create default cloud/edge pools if indicated.")
fs.BoolVar(&o.Version, "version", o.Version, "print the version information.")
}
114 changes: 114 additions & 0 deletions config/yurt-app-manager/crd/bases/apps.openyurt.io_yurtingresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,120 @@ spec:
type: object
type: object
served: true
storage: false
subresources:
status: {}
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha2
schema:
openAPIV3Schema:
description: YurtIngress is the Schema for the yurtingresses 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: YurtIngressSpec defines the desired state of YurtIngress
properties:
enabled:
type: boolean
values:
x-kubernetes-preserve-unknown-fields: true
type: object
status:
description: YurtIngressStatus defines the observed state of YurtIngress
properties:
conditions:
description: Conditions holds the conditions for the HelmRelease.
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are:
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
\n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
lastAppliedRevision:
description: LastAppliedRevision is the revision of the last successfully
applied source.
type: string
status:
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
Expand Down
Loading