Skip to content

Commit

Permalink
Add param to config webhook port (#136)
Browse files Browse the repository at this point in the history
update install doc

Signed-off-by: Duan Jiong <djduanjiong@gmail.com>
  • Loading branch information
duanjiong authored Dec 1, 2020
1 parent fd4d33d commit 2d736c0
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 29 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ The Porter LB controller is a custom controller based on the [Kubernetes control

## Installation

1. [Porter Helm Chart: Deploy Porter on Kubernetes Cluster (Recommend)](doc/porter-chart.md)
2. [Deploy Porter on Bare Metal Kubernetes Cluster](doc/deploy_baremetal.md)
3. [Test Porter on Cloud Platform with a Simulated Router](doc/simulate_with_bird.md)
1. [Deploy Porter on Bare Metal Kubernetes Cluster](doc/deploy.md)
2. [Test Porter with a Simulated Router](doc/simulate_with_bird.md)

## Build

Expand Down
4 changes: 2 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Porter LB controller 是基于 [Kubernetes controller runtime](https://github.co

## 部署插件

1. [在物理部署的 k8s 集群上部署](doc/zh/deploy_baremetal.md)
2. [在青云上用模拟路由器的方式测试](doc/zh/simulate_with_bird.md)
1. [在k8s 集群上部署](doc/zh/deploy.md)
2. [用模拟路由器的方式测试](doc/zh/simulate_with_bird.md)

## 从代码构建新的插件

Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/eip_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ type EipStatus struct {
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="cidr",type=string,JSONPath=`.spec.address`
// +kubebuilder:printcolumn:name="usage",type=integer,JSONPath=`.status.usage`
// +kubebuilder:printcolumn:name="total",type=integer,JSONPath=`.status.poolSize`
// +kubebuilder:resource:scope=Cluster,categories=ksnet
// +kubebuilder:resource:scope=Cluster,categories=networking

// Eip is the Schema for the eips API
type Eip struct {
Expand Down
2 changes: 1 addition & 1 deletion config/webhook/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
ports:
- name: https-webhook
port: 443
targetPort: 443
targetPort: webhook
selector:
control-plane: porter-manager
app: porter-manager
16 changes: 9 additions & 7 deletions config/workloads/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ spec:
# cloud controller manages should be able to run on masters
- key: "node-role.kubernetes.io/master"
effect: NoSchedule
nodeSelector:
kubernetes.io/os: linux
containers:
- command:
- /manager
args:
- --api-hosts=:50051
- --readiness-addr=:8000
# - --webhook-port=8443
image: controller:latest
imagePullPolicy: IfNotPresent
name: manager
Expand All @@ -48,21 +54,17 @@ spec:
capabilities:
add: [ "NET_ADMIN", "SYS_TIME" ]
env:
- name: POD_NAMESPACE
- name: PORTER_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: POD_ROLE
value: manager
# - name: SECRET_NAME
# value: $(WEBHOOK_SECRET_NAME)
ports:
- containerPort: 8443
name: webhook-server
- containerPort: 443
name: webhook
protocol: TCP
- containerPort: 8000
name: readness-port
Expand Down
22 changes: 12 additions & 10 deletions deploy/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,7 @@ spec:
type: object
served: true
storage: false
subresources:
status: { }
subresources: { }
- additionalPrinterColumns:
- jsonPath: .spec.address
name: cidr
Expand Down Expand Up @@ -983,7 +982,7 @@ spec:
ports:
- name: https-webhook
port: 443
targetPort: 443
targetPort: webhook
selector:
app: porter-manager
control-plane: porter-manager
Expand Down Expand Up @@ -1019,25 +1018,26 @@ spec:
- porter-manager
topologyKey: kubernetes.io/hostname
containers:
- command:
- args:
- --api-hosts=:50051
- --readiness-addr=:8000
command:
- /manager
env:
- name: POD_NAMESPACE
- name: PORTER_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: POD_ROLE
value: manager
image: kubespheredev/porter:v0.4
imagePullPolicy: IfNotPresent
name: manager
ports:
- containerPort: 8443
name: webhook-server
- containerPort: 443
name: webhook
protocol: TCP
- containerPort: 8000
name: readness-port
Expand Down Expand Up @@ -1065,6 +1065,8 @@ spec:
name: webhook-cert
readOnly: true
hostNetwork: true
nodeSelector:
kubernetes.io/os: linux
terminationGracePeriodSeconds: 10
tolerations:
- key: CriticalAddonsOnly
Expand Down Expand Up @@ -1169,4 +1171,4 @@ webhooks:
- UPDATE
resources:
- eips
sideEffects: None
sideEffects: None
12 changes: 11 additions & 1 deletion doc/bgp_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,14 @@ spec:
kubernetes.io/hostname: node4
```

The above configuration means that only Porter Manager on node4 will establish a BGP connection with 172.22.0.2.
The above configuration means that only Porter Manager on node4 will establish a BGP connection with 172.22.0.2.

## FAQ

* A: Why is it that after I modify bgpconf, the routers are gone and the neighbors are all disconnected?

Q: There is a [bug](https://github.com/osrg/gobgp/issues/2357) in GoBGP that causes a panic when you dynamically update bgpconf, so it doesn't support dynamic updates of bgpconf at the moment. For now, we recommend that you modify bgpconf and run this command `kubectl rollout restart -n porter-system deployment porter-manager`

* A: The router does not support the unexpected bgp port 179, but to some cni plugins such as calico, kube-router they all occupy port 179, and in order to handle conflicts with them, other ports are usually configured for the porter, such as 17900. What should I do at this time?

Q: You can execute DNAT on the node where the porter manager is located, converting port 179 to your corresponding port, for example, like this `iptables -t nat -A PREROUTING -s ${SWITCH_IP} -p tcp --dport 179 -j DNAT --to-destination ${MANAGER_POD_IP}:17900`
25 changes: 24 additions & 1 deletion doc/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
## Prerequisites

* Kubernetes Version >= 1.15

Porter uses the CRD resource version v1, which is only supported since kubernetes 1.15.

* BGP mode

1. The router must support the BGP protocol.
Expand Down Expand Up @@ -45,4 +49,23 @@ kubectl apply -f https://raw.githubusercontent.com/kubesphere/porter/master/depl
helm repo add test https://charts.kubesphere.io/test
helm repo update
helm install porter test/porter
```
```

## Installation on KubeSphere

* Importing the chart repo where the porter is located in the workspace
![image](https://user-images.githubusercontent.com/3678855/100723369-a486b980-33fc-11eb-90bd-9768ec26ebd3.png)

* In the project, select Create Application and choose Create from Template, select the repository you imported in the previous step, and choose porter

![image](https://user-images.githubusercontent.com/3678855/100723664-03e4c980-33fd-11eb-9ffb-7d1488705f3f.png)

![image](https://user-images.githubusercontent.com/3678855/100723740-1f4fd480-33fd-11eb-9fae-07e4be5b1474.png)

* Click on the porter, and follow the wizard. Finally, modify the chart configuration according to your own configuration, and deploy it in the project.
![image](https://user-images.githubusercontent.com/3678855/100723851-3a224900-33fd-11eb-8d7d-152137e19936.png)

![image](https://user-images.githubusercontent.com/3678855/100723964-532afa00-33fd-11eb-9dcb-d2684f482dd0.png)



10 changes: 8 additions & 2 deletions pkg/manager/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ import (
)

type GenericOptions struct {
WebhookPort int
MetricsAddr string
ReadinessAddr string
}

func NewGenericOptions() *GenericOptions {
return &GenericOptions{
MetricsAddr: ":8080",
WebhookPort: 443,
MetricsAddr: "0",
ReadinessAddr: ":8000",
}
}

func (options *GenericOptions) AddFlags(fs *pflag.FlagSet) {
fs.IntVar(&options.WebhookPort, "webhook-port", options.WebhookPort, "The port that the webhook server serves at")
fs.StringVar(&options.MetricsAddr, "metrics-addr", options.MetricsAddr, "The address the metric endpoint binds to.")
fs.StringVar(&options.ReadinessAddr, "readiness-addr", options.ReadinessAddr, "The address readinessProbe used")
}
Expand All @@ -34,11 +37,14 @@ func NewManager(cfg *rest.Config, options *GenericOptions) (ctrl.Manager, error)
Scheme: scheme,
}
if options != nil {
opts.Port = options.WebhookPort
opts.MetricsBindAddress = options.MetricsAddr
}
result, err := ctrl.NewManager(cfg, opts)

client.Client = result.GetClient()
if err == nil {
client.Client = result.GetClient()
}

return result, err
}
Expand Down

0 comments on commit 2d736c0

Please sign in to comment.