feat(k8s): add Kubernetes Helm chart for emailks service

- Create Helm chart structure with Chart.yaml and values.yaml
- Add deployment template with container configuration and environment variables
- Implement service template for gRPC port exposure
- Add service account template with security configuration
- Include horizontal pod autoscaler template for scaling capabilities
- Add helper templates for naming and label management
- Configure SMTP settings as configurable parameters in values.yaml
- Set up resource limits and requests for container performance
- Implement liveness and readiness probes for health checks
- Add support for existing secrets and custom configurations
This commit is contained in:
zhenyi
2026-06-07 22:59:06 +08:00
parent d0852ad131
commit c4824ef261
17 changed files with 353 additions and 33 deletions
+8 -18
View File
@@ -68,18 +68,7 @@ impl JobStatusStore {
guard.remove(&id);
}
pub fn all_done(&self, ids: &[u64]) -> bool {
let guard = match self.inner.read() {
Ok(g) => g,
Err(_) => return false,
};
ids.iter().all(|id| {
matches!(
guard.get(id).map(|e| e.status),
Some(SendStatus::Sent | SendStatus::Failed)
)
})
}
fn write(&self, id: u64, status: SendStatus, error: Option<String>) {
let mut guard = match self.inner.write() {
@@ -105,14 +94,15 @@ fn prune_statuses(entries: &mut HashMap<u64, JobStatusEntry>) {
let now = Instant::now();
entries.retain(|_, entry| now.duration_since(entry.updated_at) <= STATUS_TTL);
while entries.len() >= MAX_STATUS_ENTRIES {
let Some(oldest_id) = entries
// Evict at most one entry per write to avoid O(n²) behaviour under load.
// Repeated writes will gradually shrink the map if it stays above capacity.
if entries.len() >= MAX_STATUS_ENTRIES {
if let Some(oldest_id) = entries
.iter()
.min_by_key(|(_, entry)| entry.updated_at)
.map(|(id, _)| *id)
else {
break;
};
entries.remove(&oldest_id);
{
entries.remove(&oldest_id);
}
}
}