forked from apache/camel-k
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apache#4948): Move handling of IntegrationPlatform CR to a separa…
…te operator. Add a separate platformcontroller subcommand to kamel, amend install command and other installations (OLM, kustomize, helm) as needed. The platformcontroller works as the operator command but runs an operator that handles just the IntegrationPlatform crd; the operator dose not manage IntegrationPlatform crd any more.
- Loading branch information
Showing
18 changed files
with
877 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# --------------------------------------------------------------------------- | ||
# 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, | ||
# 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. | ||
# --------------------------------------------------------------------------- | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: camel-k | ||
camel.apache.org/component: platformcontroller | ||
{{- include "camel-k.labels" . | nindent 4 }} | ||
{{- with .Values.operator.annotations }} | ||
annotations: | ||
{{ toYaml . | nindent 4 }} | ||
{{- end }} | ||
name: camel-k-platformcontroller | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: camel-k-platformcontroller | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: camel-k | ||
camel.apache.org/component: platformcontroller | ||
name: camel-k-platformcontroller | ||
spec: | ||
{{- if .Values.operator.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{ toYaml .Values.operator.imagePullSecrets | indent 8 }} | ||
{{- end }} | ||
|
||
containers: | ||
- command: | ||
- kamel | ||
- platformcontroller | ||
env: | ||
- name: WATCH_NAMESPACE | ||
{{- if eq .Values.operator.global "false" }} | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
{{- else }} | ||
value: "" | ||
{{- end }} | ||
- name: LOG_LEVEL | ||
value: {{ .Values.operator.logLevel }} | ||
- name: OPERATOR_NAME | ||
value: camel-k-platformcontroller | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: KAMEL_OPERATOR_ID | ||
value: {{ .Values.operator.operatorId }} | ||
image: {{ .Values.operator.image }} | ||
imagePullPolicy: IfNotPresent | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8081 | ||
initialDelaySeconds: 20 | ||
periodSeconds: 10 | ||
name: camel-k-platformcontroller | ||
ports: | ||
- containerPort: 8080 | ||
name: metrics | ||
{{- with .Values.operator.resources }} | ||
resources: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.operator.securityContext }} | ||
{{- with .Values.operator.securityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- else }} | ||
securityContext: | ||
runAsNonRoot: true | ||
seccompProfile: | ||
type: RuntimeDefault | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
{{- end }} | ||
serviceAccountName: camel-k-operator | ||
{{- with .Values.operator.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
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, | ||
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 cmd | ||
|
||
import ( | ||
"github.com/apache/camel-k/v2/pkg/cmd/platformcontroller" | ||
"github.com/apache/camel-k/v2/pkg/platform" | ||
"github.com/apache/camel-k/v2/pkg/util/defaults" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const platformcontrollerCommand = "platformcontroller" | ||
|
||
func newCmdPlatformController(rootCmdOptions *RootCmdOptions) (*cobra.Command, *platformcontrollerCmdOptions) { | ||
options := platformcontrollerCmdOptions{} | ||
|
||
cmd := cobra.Command{ | ||
Use: "platformcontroller", | ||
Short: "Run the Camel K platform controller", | ||
Long: `Run the Camel K platform controller`, | ||
Hidden: true, | ||
PreRunE: decode(&options, rootCmdOptions.Flags), | ||
Run: options.run, | ||
} | ||
|
||
cmd.Flags().Int32("health-port", 8081, "The port of the health endpoint") | ||
cmd.Flags().Int32("monitoring-port", 8080, "The port of the metrics endpoint") | ||
cmd.Flags().Bool("leader-election", true, "Use leader election") | ||
cmd.Flags().String("leader-election-id", "", "Use the given ID as the leader election Lease name") | ||
|
||
return &cmd, &options | ||
} | ||
|
||
type platformcontrollerCmdOptions struct { | ||
HealthPort int32 `mapstructure:"health-port"` | ||
MonitoringPort int32 `mapstructure:"monitoring-port"` | ||
LeaderElection bool `mapstructure:"leader-election"` | ||
LeaderElectionID string `mapstructure:"leader-election-id"` | ||
} | ||
|
||
func (o *platformcontrollerCmdOptions) run(_ *cobra.Command, _ []string) { | ||
|
||
leaderElectionID := o.LeaderElectionID | ||
if leaderElectionID == "" { | ||
if defaults.OperatorID() != "" { | ||
leaderElectionID = platform.GetPlatformControllerLockName(defaults.OperatorID()) | ||
} else { | ||
leaderElectionID = platform.PlatformControllerLockName | ||
} | ||
} | ||
|
||
platformcontroller.Run(o.HealthPort, o.MonitoringPort, o.LeaderElection, leaderElectionID) | ||
} |
Oops, something went wrong.