@@ -61,7 +61,11 @@ Below are all of the tables in the `network_policy` database.
6161| gorp_migrations | Record of which migrations have been run. |
6262| groups | List of all apps that are either the source or destination of a network policy. |
6363| policies | List of source apps and destination metadata for network policies. |
64-
64+ | policies_info | A single row indicating the last update time of any network policy, used to save on DB queries from vxlan-policy-agent |
65+ | security_groups | Lists all security groups defined in CAPI. This is populated by policy-server-asg-syncer, and is not a source of truth. |
66+ | security_groups_info | A single row indicating the last update time of any security group info, used to save on DB queries from vxlan-policy-agent |
67+ | running_security_groups_spaces | A join table associating security groups to the spaces they are bound to for running lifecycle workloads. |
68+ | staging_security_groups_spaces | A join table associating security groups to the spaes they are bound to for staging lifecycle workloads. |
6569
6670The following tables were related to dynamic egress, which has been removed
6771from the codebase. These tables should no longer present in your database as of
@@ -181,14 +185,91 @@ mysql> select * from policies; mysql> select * from destinations;
181185 | 2 | 5346072e-7265-45f9-b70a-80c42e3f13ae | app <--+
182186 | 3 | NULL | app |
183187 +----+--------------------------------------+------+
188+ ```
189+
190+ ## <a name="security-groups-tables"</a > Security Group Related Tables
191+
192+ There are three tables storing information about security groups: security_groups, running_security_groups_spaces,
193+ and staging_security_groups_spaces.
194+
184195
196+ ### <a name =" security-groups-table " ></a > security_groups
197+ This table stores a copy of all security groups found in CAPI, so vxlan-policy-agent can query
198+ policy-server-internal for this information, rather than overwhelm CAPI with requests. Its data is
199+ synced and updated via the policy-server-asg-syncer process, and is not a source of truth for ASG data.
185200
186201```
202+ mysql> describe security_groups;
203+ +-----------------+--------------+------+-----+---------+----------------+
204+ | Field | Type | Null | Key | Default | Extra |
205+ +-----------------+--------------+------+-----+---------+----------------+
206+ | id | bigint | NO | PRI | NULL | auto_increment |
207+ | guid | varchar(36) | NO | UNI | NULL | |
208+ | name | varchar(255) | NO | | NULL | |
209+ | rules | mediumtext | YES | | NULL | |
210+ | staging_default | tinyint(1) | YES | MUL | 0 | |
211+ | running_default | tinyint(1) | YES | MUL | 0 | |
212+ | staging_spaces | json | YES | | NULL | |
213+ | running_spaces | json | YES | | NULL | |
214+ +-----------------+--------------+------+-----+---------+----------------+
215+ ```
216+
217+ | Field | Note |
218+ | ---| ---|
219+ | id | An internal id for each record |
220+ | guid | The CAPI GUID of the security group |
221+ | name | The name of the security group as it appears in CAPI |
222+ | hash | A SHA256 hash of the ASG data, used to check whether records need updating during policy-server-asg-syncer polls |
223+ | rules | The rules associated with the ASG defined in CAPI |
224+ | staging_default | Whether or not this is a globally bound security group for ` staging ` lifecycles |
225+ | running_default | Whether or not this is a globally bound security group for ` running ` lifecycles |
226+ | staging_spaces | A json list of all spaces this security group is bound to for the ` staging ` lifecycle |
227+ | running_spaces | A json list of all spaces this security group is bound to for the ` running ` lifecycle |
228+
229+ ### <a name =" running-security-groups-spaces-table " ></a > running_security_groups_spaces
230+ This table is a join table to enable faster querying of security_groups when filtering by
231+ running_space guids. It is synced and updated via the policy-server-asg-syncer process, and is not a source of
232+ truth for ASG data.
187233
234+ ```
235+ mysql> describe running_security_groups_spaces;
236+ +---------------------+--------------+------+-----+---------+-------+
237+ | Field | Type | Null | Key | Default | Extra |
238+ +---------------------+--------------+------+-----+---------+-------+
239+ | space_guid | varchar(255) | NO | PRI | NULL | |
240+ | security_group_guid | varchar(255) | NO | PRI | NULL | |
241+ +---------------------+--------------+------+-----+---------+-------+
242+ ```
243+
244+ | Field | Note|
245+ | ---| ---|
246+ | space_guid | This value is the CAPI guid for the space bound to a given security group via the ` running ` app lifecycle |
247+ | security_group_guid | This value is the CAPI guid for the security group bound to a given space via the ` running ` app lifecycle |
248+
249+
250+ ### <a name =" staging-security-groups-spaces-table " ></a > staging_security_groups_spaces
251+ This table is a join table to enable faster querying of security_groups when filtering by
252+ staging_space guids. It is synced and updated via the policy-server-asg-syncer process, and is not a source of
253+ truth for ASG data.
254+
255+ ```
256+ mysql> describe staging_security_groups_spaces;
257+ +---------------------+--------------+------+-----+---------+-------+
258+ | Field | Type | Null | Key | Default | Extra |
259+ +---------------------+--------------+------+-----+---------+-------+
260+ | space_guid | varchar(255) | NO | PRI | NULL | |
261+ | security_group_guid | varchar(255) | NO | PRI | NULL | |
262+ +---------------------+--------------+------+-----+---------+-------+
263+ ```
264+
265+ | Field | Note|
266+ | ---| ---|
267+ | space_guid | This value is the CAPI guid for the space bound to a given security group via the ` staging ` app lifecycle |
268+ | security_group_guid | This value is the CAPI guid for the security group bound to a given space via the ` staging ` app lifecycle |
188269
189270## <a name =" migrations-tables " ></a > Migration Related Tables
190271
191- There are two tables related to migraitons : gorp_migrations and gorp_lock.
272+ There are two tables related to migrations : gorp_migrations and gorp_lock.
192273
193274### <a name =" gorp-mirations-table " ></a > gorp_migrations
194275This table tracks what database migrations have been applied.
0 commit comments