Documentation
¶
Overview ¶
Package secgroup implements security groups (§8.3): AWS-style allow rules between containers, attached to services. It validates rules, compiles every group into the sets and rules agents enforce with nftables, and answers reachability questions with the same semantics.
Index ¶
Constants ¶
const ( KindAny = "any" // anywhere KindCluster = "cluster" // the cluster nodes' mesh addresses KindCIDR = "cidr" // an IPv4 address or CIDR KindGroup = "group" // members of a security group KindService = "service" // tasks of a service KindEnvironment = "environment" // every task in an environment KindProject = "project" // every task in a project KindSelfEnv = "self-env" // the member's own environment KindSelfProject = "self-project" KindSelf = "self" // members of the rule's own group )
Peer kinds.
const EtcdServiceID = "etcd"
EtcdServiceID matches the platform etcd's containers (label syncloud.service_id).
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
func Compile(m *Model) *agentv1.SecurityPolicy
Compile turns every group into the policy agents enforce.
Types ¶
type Endpoint ¶
type Endpoint struct {
ServiceID string
Project, Env string // a standalone job run
IP string
Platform bool
}
Endpoint is one side of a connection: a service's task, a job run without a service, an address, or the platform (Traefik and the controller).
type Group ¶
type Group struct {
ID, Project, Name string
Default bool
Inbound, Outbound []Rule
Services []string // attached service IDs
}
Group is a security group with parsed rules.
func DatabaseGroup ¶
DatabaseGroup is the security group a database uses: its own members on any port, and its access list over TCP. Outbound is open (replication, Sentinel and DNS).
func EtcdGroup ¶
EtcdGroup is the platform etcd's group: its members on any port, and the PostgreSQL members on the client port.
func FromStore ¶
func FromStore(g store.SecurityGroup) Group
FromStore parses a stored group's rules.
type Match ¶
type Match struct {
GroupID string `json:"groupId"`
Group string `json:"group"` // project/name
Direction string `json:"direction"`
Index int `json:"index"`
Rule Rule `json:"rule"`
}
Match names the rule that allowed a connection.
type Model ¶
type Model struct {
Envs map[string][]string // project -> environment names
Services []Service
Standalone []Standalone
Groups []Group
ClusterIPs []string
PlatformIPs []string
// contains filtered or unexported fields
}
Model is everything compilation and evaluation need.
func Load ¶
Load builds the model from the database: every group, service, task and job run address, and the cluster's node addresses.
func (*Model) EffectiveLines ¶
EffectiveLines lists what applies to a service, one line per rule; the preview diffs these.
func (*Model) Evaluate ¶
Evaluate answers whether src can open a connection to dst (a service's tasks) on proto/port, and which rules decide it.
func (*Model) GroupsOf ¶
GroupsOf returns the groups a service uses: those attached to it, or its project's default group.
func (*Model) ResetIndex ¶
func (m *Model) ResetIndex()
ResetIndex must be called after changing a model's groups or services.
type Peer ¶
Peer is a parsed rule peer.
type Rule ¶
type Rule struct {
Protocol string `json:"protocol"` // tcp | udp | icmp | any
Ports string `json:"ports"` // "", "5432", "8000-8100"
Peers []string `json:"peers"` // sources (inbound) or destinations (outbound)
Description string `json:"description"`
}
Rule allows traffic to (inbound) or from (outbound) a group's members.
type Standalone ¶
type Standalone struct {
Project, Env, IP string
}
Standalone is a job run that belongs to no service.