-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce permission of antrea-agent service account
Remove the update permission for services/status of antrea-agent service account. Remove the optimization for ExternalTrafficPolicy setting to Local cases in ServiceExternalIP feature accordingly. Introduce "antctl get serviceexternalip" command for the agent to make checking the assigned Node of external IPs easier. Signed-off-by: Xu Liu <xliu2@vmware.com>
- Loading branch information
Showing
15 changed files
with
333 additions
and
222 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -53,5 +53,6 @@ rules: | |
- /ovstracing | ||
- /podinterfaces | ||
- /featuregates | ||
- /serviceexternalip | ||
verbs: | ||
- get |
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
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
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
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,70 @@ | ||
// Copyright 2022 Antrea 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 serviceexternalip | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
||
"antrea.io/antrea/pkg/antctl/transform/common" | ||
"antrea.io/antrea/pkg/features" | ||
"antrea.io/antrea/pkg/querier" | ||
) | ||
|
||
// HandleFunc creates a http.HandlerFunc which uses an ServiceExternalIPStatusQuerier | ||
// to query Service external IP status. | ||
func HandleFunc(sq querier.ServiceExternalIPStatusQuerier) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
name := r.URL.Query().Get("name") | ||
ns := r.URL.Query().Get("namespace") | ||
if !features.DefaultFeatureGate.Enabled(features.ServiceExternalIP) { | ||
http.Error(w, "ServiceExternalIP is not enabled", http.StatusServiceUnavailable) | ||
return | ||
} | ||
result := sq.GetServiceExternalIPStatus() | ||
var response []Response | ||
for _, r := range result { | ||
if (len(name) == 0 || name == r.ServiceName) && (len(ns) == 0 || ns == r.Namespace) { | ||
response = append(response, Response{r}) | ||
} | ||
} | ||
if len(name) > 0 && len(response) == 0 { | ||
w.WriteHeader(http.StatusNotFound) | ||
return | ||
} | ||
if err := json.NewEncoder(w).Encode(response); err != nil { | ||
http.Error(w, "Failed to encode response: "+err.Error(), http.StatusInternalServerError) | ||
} | ||
} | ||
} | ||
|
||
// Response describes the response struct of serviceexternalip command. | ||
type Response struct { | ||
querier.ServiceExternalIPInfo | ||
} | ||
|
||
var _ common.TableOutput = (*Response)(nil) | ||
|
||
func (r Response) GetTableHeader() []string { | ||
return []string{"NAMESPACE", "NAME", "EXTERNAL-IP-POOL", "EXTERNAL-IP", "ASSIGNED-NODE"} | ||
} | ||
|
||
func (r Response) GetTableRow(_ int) []string { | ||
return []string{r.Namespace, r.ServiceName, r.ExternalIPPool, r.ExternalIP, r.AssignedNode} | ||
} | ||
|
||
func (r Response) SortRows() bool { | ||
return true | ||
} |
Oops, something went wrong.