You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ki...@apache.org on 2022/06/30 18:34:28 UTC
[trafficserver-ingress-controller] branch master updated: Add opts for disabling debug and tuning resync (#132)
This is an automated email from the ASF dual-hosted git repository.
kichan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new f387fe2 Add opts for disabling debug and tuning resync (#132)
f387fe2 is described below
commit f387fe2e90acc51b4dd438656e1a00889f9f0232
Author: Kit Chan <ki...@apache.org>
AuthorDate: Thu Jun 30 11:34:22 2022 -0700
Add opts for disabling debug and tuning resync (#132)
* add opts for disabling debug and tuning resync
* add documentation
---
bin/entry.sh | 11 +++++++++--
docs/TUTORIAL.md | 8 ++++++++
k8s/traffic-server/ats-deployment.yaml | 2 ++
main/main.go | 4 ++++
watcher/watcher.go | 7 ++++---
5 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/bin/entry.sh b/bin/entry.sh
index a875ee8..1c69bee 100755
--- a/bin/entry.sh
+++ b/bin/entry.sh
@@ -41,8 +41,15 @@ touch /opt/ats/var/run/ts-alive
DISTRIB_ID=gentoo /opt/ats/bin/trafficserver start
if [ -z "${INGRESS_NS}" ]; then
- INGRESS_NS="all"
+ INGRESS_NS="all"
fi
-/opt/ats/go/bin/src/github.com/apache/trafficserver-ingress-controller/ingress_ats -atsIngressClass="$INGRESS_CLASS" -atsNamespace="$POD_NAMESPACE" -namespaces="$INGRESS_NS" -ignoreNamespaces="$INGRESS_IGNORE_NS" -useInClusterConfig=T 2>>/opt/ats/var/log/ingress/ingress_ats.err
+if [ -z "${RESYNC_PERIOD}" ]; then
+ RESYNC_PERIOD="0"
+fi
+if [ -z "${INGRESS_DEBUG}" ]; then
+ /opt/ats/go/bin/src/github.com/apache/trafficserver-ingress-controller/ingress_ats -atsIngressClass="$INGRESS_CLASS" -atsNamespace="$POD_NAMESPACE" -namespaces="$INGRESS_NS" -ignoreNamespaces="$INGRESS_IGNORE_NS" -useInClusterConfig=T -resyncPeriod="$RESYNC_PERIOD"
+else
+ /opt/ats/go/bin/src/github.com/apache/trafficserver-ingress-controller/ingress_ats -atsIngressClass="$INGRESS_CLASS" -atsNamespace="$POD_NAMESPACE" -namespaces="$INGRESS_NS" -ignoreNamespaces="$INGRESS_IGNORE_NS" -useInClusterConfig=T -resyncPeriod="$RESYNC_PERIOD" 2>>/opt/ats/var/log/ingress/ingress_ats.err
+fi
diff --git a/docs/TUTORIAL.md b/docs/TUTORIAL.md
index 77ed667..7f6ab9c 100644
--- a/docs/TUTORIAL.md
+++ b/docs/TUTORIAL.md
@@ -142,6 +142,14 @@ You can specify a different
You can specify extra plugins for [plugin.config](https://docs.trafficserver.apache.org/en/8.1.x/admin-guide/files/plugin.config.en.html) by providing environment variable `EXTRA_PLUGIN_FNAME`. Its contents can be provided through a ConfigMap and loaded to a volume mounted for the ATS container (Example [here](https://kubernetes.io/docs/concepts/storage/volumes/#configmap) ).
+#### Enabling Controller Debug Log
+
+You can enable debug for the controller by providing environment variable `INGRESS_DEBUG`. See an example commented out [here](../k8s/traffic-server/ats-deployment.yaml).
+
+#### Tune Resync Period of Controller
+
+You can adjust the resync period for the controller by providing environment variable `RESYNC_PRIOD`.
+
### Logging and Monitoring
#### Fluentd
diff --git a/k8s/traffic-server/ats-deployment.yaml b/k8s/traffic-server/ats-deployment.yaml
index 7749f4f..3d67ef3 100644
--- a/k8s/traffic-server/ats-deployment.yaml
+++ b/k8s/traffic-server/ats-deployment.yaml
@@ -67,6 +67,8 @@ spec:
fieldRef:
fieldPath: metadata.namespace
# Optional environment variables
+# - name: INGRESS_DEBUG
+# value: "true"
# - name: INGRESS_CLASS
# value: "ats"
# - name: LOG_CONFIG_FNAME
diff --git a/main/main.go b/main/main.go
index e636c00..f79d9a2 100644
--- a/main/main.go
+++ b/main/main.go
@@ -22,6 +22,7 @@ import (
"os/signal"
"strings"
"syscall"
+ "time"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
@@ -54,6 +55,8 @@ var (
atsNamespace = flag.String("atsNamespace", "default", "Name of Namespace the ATS pod resides.")
atsIngressClass = flag.String("atsIngressClass", "", "Ingress Class of Ingress object that ATS will retrieve routing info from")
+
+ resyncPeriod = flag.Duration("resyncPeriod", 0*time.Second, "Resync period for the cache of informer")
)
func init() {
@@ -149,6 +152,7 @@ func main() {
watcher := w.Watcher{
Cs: clientset,
ATSNamespace: *atsNamespace,
+ ResyncPeriod: *resyncPeriod,
Ep: &endpoint,
StopChan: stopChan,
}
diff --git a/watcher/watcher.go b/watcher/watcher.go
index 2079c0f..6423dc2 100644
--- a/watcher/watcher.go
+++ b/watcher/watcher.go
@@ -43,6 +43,7 @@ import (
type Watcher struct {
Cs kubernetes.Interface
ATSNamespace string
+ ResyncPeriod time.Duration
Ep *endpoint.Endpoint
StopChan chan struct{}
}
@@ -61,7 +62,7 @@ func (w *Watcher) Watch() error {
igHandler := IgHandler{"ingresses", w.Ep}
igListWatch := cache.NewListWatchFromClient(w.Cs.NetworkingV1().RESTClient(), igHandler.GetResourceName(), v1.NamespaceAll, fields.Everything())
err := w.allNamespacesWatchFor(&igHandler, w.Cs.NetworkingV1().RESTClient(),
- fields.Everything(), &nv1.Ingress{}, 0, igListWatch)
+ fields.Everything(), &nv1.Ingress{}, w.ResyncPeriod, igListWatch)
if err != nil {
return err
}
@@ -69,7 +70,7 @@ func (w *Watcher) Watch() error {
epHandler := EpHandler{"endpoints", w.Ep}
epListWatch := cache.NewListWatchFromClient(w.Cs.CoreV1().RESTClient(), epHandler.GetResourceName(), v1.NamespaceAll, fields.Everything())
err = w.allNamespacesWatchFor(&epHandler, w.Cs.CoreV1().RESTClient(),
- fields.Everything(), &v1.Endpoints{}, 0, epListWatch)
+ fields.Everything(), &v1.Endpoints{}, w.ResyncPeriod, epListWatch)
if err != nil {
return err
}
@@ -78,7 +79,7 @@ func (w *Watcher) Watch() error {
targetNs := make([]string, 1)
targetNs[0] = w.Ep.ATSManager.(*proxy.ATSManager).Namespace
err = w.inNamespacesWatchFor(&cmHandler, w.Cs.CoreV1().RESTClient(),
- targetNs, fields.Everything(), &v1.ConfigMap{}, 0)
+ targetNs, fields.Everything(), &v1.ConfigMap{}, w.ResyncPeriod)
if err != nil {
return err
}