Documentation
¶
Index ¶
- Constants
- func StartDaemonset(args DaemonsetArgs) error
- type Daemonset
- func (d *Daemonset) KubernetesPodEventsWorker(done <-chan struct{})
- func (d *Daemonset) PodsHealthWorker(done <-chan struct{})
- func (d *Daemonset) Run() error
- func (d *Daemonset) SignalApiDumpProcessToStop(podUID types.UID, stopErr error) error
- func (d *Daemonset) StartApiDumpProcess(podUID types.UID) error
- func (d *Daemonset) StartProcessInExistingPods() error
- func (d *Daemonset) StopAllApiDumpProcesses()
- func (d *Daemonset) TelemetryWorker(done <-chan struct{})
- type DaemonsetArgs
- type PodArgs
- type PodCreds
- type PodTrafficMonitorState
Constants ¶
const ( // Pod environment variables POSTMAN_INSIGHTS_PROJECT_ID = "POSTMAN_INSIGHTS_PROJECT_ID" POSTMAN_INSIGHTS_API_KEY = "POSTMAN_INSIGHTS_API_KEY" POSTMAN_INSIGHTS_DISABLE_REPRO_MODE = "POSTMAN_INSIGHTS_DISABLE_REPRO_MODE" POSTMAN_INSIGHTS_DROP_NGINX_TRAFFIC = "POSTMAN_INSIGHTS_DROP_NGINX_TRAFFIC" POSTMAN_INSIGHTS_AGENT_RATE_LIMIT = "POSTMAN_INSIGHTS_AGENT_RATE_LIMIT" // Daemonset environment variables POSTMAN_INSIGHTS_ENV = "POSTMAN_ENV" // This is same as root POSTMAN_ENV POSTMAN_INSIGHTS_VERIFICATION_TOKEN = "POSTMAN_INSIGHTS_VERIFICATION_TOKEN" POSTMAN_INSIGHTS_CLUSTER_NAME = "POSTMAN_INSIGHTS_CLUSTER_NAME" // Workers intervals DefaultTelemetryInterval = 5 * time.Minute DefaultPodHealthCheckInterval = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func StartDaemonset ¶
func StartDaemonset(args DaemonsetArgs) error
Types ¶
type Daemonset ¶
type Daemonset struct { ClusterName string InsightsEnvironment string InsightsReproModeEnabled bool InsightsRateLimit float64 KubeClient kube_apis.KubeClient CRIClient *cri_apis.CriClient FrontClient rest.FrontClient // Note: Only filtered pods are stored in this map, i.e., they have required env vars // and do not have the agent sidecar container PodArgsByNameMap sync.Map // WaitGroup to wait for all apidump processes to stop ApidumpProcessesWG sync.WaitGroup PodHealthCheckInterval time.Duration TelemetryInterval time.Duration }
func (*Daemonset) KubernetesPodEventsWorker ¶
func (d *Daemonset) KubernetesPodEventsWorker(done <-chan struct{})
KubernetesPodEventsWorker listens for Kubernetes events and handles them accordingly. It runs indefinitely until the provided done channel is closed.
func (*Daemonset) PodsHealthWorker ¶
func (d *Daemonset) PodsHealthWorker(done <-chan struct{})
PodsHealthWorker periodically checks the health of the pods and prunes stopped processes. It runs until the provided done channel is closed.
func (*Daemonset) Run ¶
Run starts the Daemonset and its workers, and waits for a termination signal. It performs the following steps: 1. Starts all the workers. 4. Starts the process in the existing pods. 5. Waits for a termination signal (SIGINT or SIGTERM). 6. Signals all workers to stop. 7. Stops all apidump processes. 8. Exits the daemonset agent.
func (*Daemonset) SignalApiDumpProcessToStop ¶ added in v0.37.3
SignalApiDumpProcessToStop signals the API dump process to stop for a given pod identified by its UID. It retrieves the process's stop channel object from a map and sends a stop signal to trigger apidump shutdown.
func (*Daemonset) StartApiDumpProcess ¶
StartApiDumpProcess initiates the API dump process for a given pod identified by its UID. It retrieves the pod arguments, changes the pod's traffic monitoring state, and starts the API dump process in a separate goroutine. The goroutine handles errors and state changes, and ensures the process is stopped properly.
func (*Daemonset) StartProcessInExistingPods ¶
StartProcessInExistingPods starts apidump process in existing pods that do not have the agent sidecar container and required env vars.
func (*Daemonset) StopAllApiDumpProcesses ¶
func (d *Daemonset) StopAllApiDumpProcesses()
StopAllApiDumpProcesses stops all API dump processes for the Daemonset. It iterates over the PodArgsByNameMap and performs the following actions for each pod: 1. Changes the pod's traffic monitor state to DaemonSetShutdown. 2. Stops the API dump process for the pod. 3. Logs any errors encountered during the state change or stopping process. 4. Removes the pod from the PodArgsByNameMap. 5. Wait for all the apidump processes to stop.
func (*Daemonset) TelemetryWorker ¶
func (d *Daemonset) TelemetryWorker(done <-chan struct{})
TelemetryWorker starts a worker that periodically sends telemetry data and dumps the state of the Pods API dump process. The worker runs until the provided done channel is closed.
type DaemonsetArgs ¶ added in v0.35.0
type PodArgs ¶
type PodArgs struct { // apidump related fields InsightsProjectID akid.ServiceID TraceTags tags.SingletonTags ReproMode bool DropNginxTraffic bool AgentRateLimit float64 // Pod related fields PodName string ContainerUUID string PodCreds PodCreds // for state management PodTrafficMonitorState PodTrafficMonitorState StateChangeMutex sync.Mutex `json:"-"` // send stop signal to apidump process StopChan chan error `json:"-"` }
func NewPodArgs ¶
type PodTrafficMonitorState ¶
type PodTrafficMonitorState string
const ( // Pod Lifecycle states PodPending PodTrafficMonitorState = "PodPending" // When agent will receive pod added event PodRunning PodTrafficMonitorState = "PodRunning" // When the pod is running and agent can start the apidump process PodSucceeded PodTrafficMonitorState = "PodSucceeded" // When the pod is terminated successfully, agent will receive pod deleted event PodFailed PodTrafficMonitorState = "PodFailed" // When the pod is terminated with failure, agent will receive pod deleted event PodTerminated PodTrafficMonitorState = "PodTerminated" // custom: When the pod is terminated with unknown status RemovePodFromMap PodTrafficMonitorState = "RemovePodFromMap" // custom: Final state after which pod will be removed from the map // Traffic monitoring states TrafficMonitoringRunning PodTrafficMonitorState = "TrafficMonitoringRunning" // When apidump process is running for the pod TrafficMonitoringFailed PodTrafficMonitorState = "TrafficMonitoringFailed" // When apidump process is errored for the pod TrafficMonitoringEnded PodTrafficMonitorState = "TrafficMonitoringEnded" // When apidump process is ended without any issue for the pod // Daemonset shutdown state DaemonSetShutdown PodTrafficMonitorState = "DaemonSetShutdown" // When the daemonset agent starts the shutdown process )
Different states of pod traffic monitoring The state transition is as follows: State diagram: https://whimsical.com/pod-monitoring-state-diagram-Ny5HqFJxz2fntz6ZM6bj2k