yaml

yaml
# ClusterIP Service (internal only)
apiVersion: v1
kind: Service
metadata:
  name: web-app
  namespace: production

Kubernetes Services and Ingress for traffic routing

kubernetes k8s services
by Ryan Nakamura 2 tabs
yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: api-ingress
  namespace: production
spec:

Kubernetes NetworkPolicy for namespace level traffic control

kubernetes networkpolicy cluster-security
by Kai Nakamura 1 tab
dockerfile
FROM node:20-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat

FROM base AS deps
COPY package.json package-lock.json ./

Docker multi-stage build for Next.js

docker nextjs multi-stage
by codesnips 4 tabs
ruby
class User < ApplicationRecord
  has_many :posts
  has_many :comments

  scope :digest_subscribers, -> {
    where(digest_opt_in: true).where.not(confirmed_at: nil)

Weekly Digest Emails in Rails with a Cron Job and Query Scopes

rails activejob sidekiq-cron
by codesnips 4 tabs
php
<?php

namespace App\Event;

use Symfony\Contracts\EventDispatcher\Event;

Symfony: Send a Welcome Email Asynchronously with Messenger and an Event Subscriber

symfony messenger async
by codesnips 4 tabs
python
from typing import Literal, Tuple, Type

from pydantic import BaseModel, PostgresDsn, RedisDsn
from pydantic_settings import (
    BaseSettings,
    PydanticBaseSettingsSource,

Layered Pydantic Settings: Env Vars Over a YAML Defaults File

pydantic configuration settings
by codesnips 4 tabs
yaml
production:
  primary:
    adapter: postgresql
    url: <%= ENV['DATABASE_URL'] %>
    pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
  primary_replica:

Database read replicas for scaling reads

rails postgresql scaling
by Alex Kumar 3 tabs
java
package com.example.demo.feature;

import org.togglz.core.Feature;
import org.togglz.core.annotation.EnabledByDefault;
import org.togglz.core.annotation.Label;
import org.togglz.core.context.FeatureContext;

Feature flags for gradual rollouts

java feature-flags togglz
by David Kumar 4 tabs
yaml
amazon:
  service: S3
  access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
  secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
  region: us-east-1
  bucket: <%= Rails.application.credentials.dig(:aws, :bucket) %>

ActiveStorage for file uploads

rails activestorage file-uploads
by Alex Kumar 3 tabs
yaml
# Service Account for the application
apiVersion: v1
kind: ServiceAccount
metadata:
  name: web-app-sa
  namespace: production

Kubernetes RBAC and service account security

kubernetes k8s rbac
by Ryan Nakamura 1 tab
dockerfile
# Build stage
FROM maven:3.9-eclipse-temurin-21 AS build
WORKDIR /app

# Copy dependency definitions
COPY pom.xml .

Docker containerization for Spring Boot

java docker spring-boot
by David Kumar 3 tabs
php
<?php

namespace App\Message;

final class SyncCustomerMessage
{

Retrying Flaky HTTP Calls with a Symfony Messenger Retry Strategy and Failure Handler

symfony messenger retry
by codesnips 3 tabs